I need help with a bash script that I try to improve. I could not find answer so far, maybe because I'm not to familiar with the terminology so feel free to correct my language.
I have a script that looks like:
NODES="node_a node_b node_c"
for NODE in $NODES
do
FILE=${NODE}.log
connect << EOF > $FILE
findVersion $NODE
EOF
echo "$NODE completed."
done
This works fine. My problem is that `connect' command takes long time to start and I wanted to do for loop inside the connect << EOF > ..... EOF construction so my connect command will be executed only once. The issue is that for will not work inside there and will be written to the input of connect command where it miserably fails.
Thank you for reply. Of course your suggestion will work :). The problem is that my list is not limited to three entries. It's more closer to hundreds It is generated automatically so hard coding it in the scripts seems to be an ugly way to go. I don't know, maybe what I'm trying to do is not possible in bash?
Thanks,
PN.
for NODE in $NODES
do
echo " findVersion $NODE"
done | connect
However, if you want a separate log file for each node, you can't batch them like that (unless there is a way to specify a separate output file for each command inside the connect script).