Run SQL command for a list of devices

Hi
Please help me to resolve.

Question:

I can run this command to change the mode of a device with id=500 as below

dbc "select device mode=3 where id=500;"

How can i run the same query with a file contaning n number of ids ?

file1.txt
12
234
34
500
34
45

Thanks in advance.

Use a loop, something like:

#/bin/sh

while read num
do
  sqlstring="select device mode=3 where id="$num";"
  dbc "$sqlstring"
done < file1.txt

You can do this by the following script.

while read line 
do
dbc "select device mode=3 where id=$line;"
done < file1.txt

Thank you very much Frank and Raj, it works!!!

One small thing I added the dbc path for script to recog the dbc command.