home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Linux and Unix
Ask a Tech Support Question (free)!

Running commands in loop??

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1443
Discussions: 200,931, Posts: 2,379,159, Members: 246,297
Old July 24th, 2008, 12:58 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 1
Running commands in loop??

Hi All,

I want to execute a set of commands in unix in sequence.

say,

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..!!


Regards,

Bruce
brucewayne is offline   Reply With Quote
Old July 24th, 2008, 01:29 PM     #2 (permalink)
Ultimate Member
 
SeanC's Avatar
 
Join Date: Oct 2001
Location: Toronto Canada
Posts: 4,698
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.
__________________
AMD Phenom Q9500 Quad-Core 2.2ghz / Asus M3A78-EMH HDMI / 4GB PC667 RAM / 320GB SATA II
SeanC is offline   Reply With Quote
Old September 10th, 2008, 02:09 AM     #3 (permalink)
Junior Member
 
Join Date: Sep 2008
Posts: 3
while [ 1 ]; do
command1
command2
....
done
trueg is offline   Reply With Quote
Old September 12th, 2008, 12:45 AM     #4 (permalink)
Ultimate Member
 
pbharris's Avatar
 
Join Date: Oct 2001
Location: Chicago, IL
Posts: 2,514
Send a message via ICQ to pbharris Send a message via AIM to pbharris Send a message via Yahoo to pbharris
Code:
for i in `ls 20010*`;do sh ABC.sh job1 $i C/..../log;done
those are tick marks - not quote marks.
__________________
Odds are very good there are several spelling mistakes in this post.
pbharris is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Having problems with running games with TeamSpeak, can't speak while running Naga Technical Support 0 March 22nd, 2007 10:23 PM
what do these commands do? gigahertz205 Networking and Internet 4 March 7th, 2005 08:46 PM
Which Commands ? Regulus Applications and Operating Systems 11 October 29th, 2004 10:13 PM
commands maotx General Tech Discussion 6 June 20th, 2003 10:07 AM
Linux Commands ridemonkey Webmastering and Programming 6 September 10th, 2002 11:15 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2872)
Obama the Muslim (14)
California Passes Anti-Flat-HDTV Le.. (39)
Is the PSU I received dead? (10)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
HIS HD5770 graphic card question (15)
Print spooler problem (13)
Foreign voltage (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
Ideal cheap graph card for PC-Gamin.. (16)
New Computer wont recognize XP disc (7)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
Wireless Televisions. (0)
Install XP pro and a Vista laptop ?? (11)
Partition Magic caused HDD problem (2)
Graphics Card Upgrade Question (1)
favorit (1)
solutions for virtical white lines on.. (1)
Regular Build (3)
Ideal cheap graph card for PC-Gaming? (16)
Fire in DVD (2)
Modern Warfare For the PC (33)
radeon x850xt platinum & shader 3 (3)
Have you switched yet? (84)
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)


All times are GMT -4. The time now is 07:12 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28