Thread: Running commands in loop??
July 23rd, 2008, 11:58 PM #1
- Join Date
- Jul 2008
Running commands in loop??
I want to execute a set of commands in unix in sequence.
sh ABC.sh job1 20010505 C/..../log
sh ABC.sh job1 20010506 C/..../log
sh ABC.sh job1 20010507 C/..../log
sh ABC.sh job1 20010508 C/..../log
How i can write a loop to execute these commands one after another in sequence.
Also, untill the first command is runs completely, the second should not get executed.
The only variant in all these commands is the date.
I am just learning unix scripts...if someone could pitch in with their suggestions it would be great..!!
July 24th, 2008, 12:29 PM #2
I'm not a Unix scripting expert but I'll give it a shot.
So do you want to run them in a loop one at a time repeatedly? Or just run them one at a time once per execution of the script?
If you just want to run them once per execution, just type them into the script file, one per line. Don't forget any script headers that are needed. I think they will run one at a time, waiting for the previous one to finish before starting the next.
If you want to have them run repeatedly, you'll need to use some type of FOR loop in the scripting.
September 10th, 2008, 01:09 AM #3
- Join Date
- Sep 2008
while [ 1 ]; do
September 11th, 2008, 11:45 PM #4Code:
for i in `ls 20010*`;do sh ABC.sh job1 $i C/..../log;doneOdds are very good there are several spelling mistakes in this post.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By Naga in forum Technical SupportReplies: 0Last Post: March 22nd, 2007, 09:23 PM
By gigahertz205 in forum Networking and InternetReplies: 4Last Post: March 7th, 2005, 08:46 PM
By Regulus in forum Applications and Operating SystemsReplies: 11Last Post: October 29th, 2004, 09:13 PM
By maotx in forum General Tech DiscussionReplies: 6Last Post: June 20th, 2003, 09:07 AM
By ridemonkey in forum Webmastering and ProgrammingReplies: 6Last Post: September 10th, 2002, 10:15 AM