## winbatch 7

Here's what I'm trying to do... I want to connect to a command line application and send it instructions from inside a script. I need to do a loop as there are multiple things I want to do. I was able to accomplish this by connecting and disconnecting inside the loop, but I'd rather connect once, do my loop and then disconnect once. Is that possible? Here is my current script. (Note I'm connecting to a queue manager and executing something for each queue defined in a text file).

#!/usr/bin/ksh
if [ $# -lt 2 ] then echo "USAGE:$0 qm queue_file"
exit 1
fi

qm=$1 file=$2
if [ ! -r $file ] then echo "${file} does not exist...."
exit 1
fi
cat ${file} | while read queueName do runmqsc${qm}<<!
display ql(${queueName}) CURDEPTH end ! done (So basically, the 'runmqsc' should only be executed once and the 'end' should only be executed once...) ## winbatch 7 I came up with a workaround (which is to have it create a different script and then run that script). Let me know if there is a better way: #!/usr/bin/ksh if [$# -lt 2 ]
then
echo "USAGE: $0 qm queue_file" exit 1 fi qm=$1
file=$2 if [ ! -r$file ]
then
echo "${file} does not exist...." exit 1 fi if [ ! -r run.sh ] then \rm run.sh fi echo "runmqsc${qm}<<!" > run.sh
cat ${file} | while read queueName do echo "display ql(${queueName}) CURDEPTH">> run.sh
done
echo "end" >> run.sh
echo "!" >> run.sh
chmod 777 run.sh
run.sh