RSS Forums RSS
Please support our Shell Scripting advertiser: Programming Forums
Views: 2971 | Replies: 1
Reply
Join Date: Feb 2005
Posts: 464
Reputation: winbatch is on a distinguished road 
Rep Power: 4
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

How to loop inside application via script

  #1  
Jul 27th, 2005
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...)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Posts: 464
Reputation: winbatch is on a distinguished road 
Rep Power: 4
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: How to loop inside application via script

  #2  
Jul 27th, 2005
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:01 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC