indexdata/yaz

Efficient way to use yaz-client in a loop?

vfscalfani opened this issue · 2 comments

Hi,

I'm trying to figure out the best way to run multiple queries (e.g., from a list) using yaz-client, and I'm wondering if you may be able to offer any tips. Here is where I am at:

Method 1:

I can create a file, mysearches, that looks something like this:

   open library.ua.edu:7090/voyager
   find @1=7 "1683925041"
   sleep 1
   find @1=7 "9780470183014"
   sleep 1
   find @1=7 "1565925858"
   quit

and then use the -f option:

yaz-client -f mysearches

The challenge with that approach is then I have to format the input file with find, sleep, etc.

Here is method 2, which I think is slightly easier:

for isbn in \
    "1683925041" \
    "9780470183014" \
    "1565925858" \
    "9780136778851" \
    "1785284444"
do
    printf "open library.ua.edu:7090/voyager\nfind @1=7 "$isbn"\nquit\n" |
    yaz-client -f /dev/stdin
    sleep 1
done

That's close to what I am looking for, but it seems not ideal to open and close the connection each time? Any ideas to improve method 2 or maybe I am missing a better option with yaz-client?

Thanks very much,

Vin

Hi @MikeTaylor. Thanks for this!