+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    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

  2. #2
    Ultimate Member SeanC's Avatar
    Join Date
    Oct 2001
    Location
    Toronto Canada
    Posts
    4,803
    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.

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    3
    while [ 1 ]; do
    command1
    command2
    ....
    done

  4. #4
    Ultimate Member pbharris's Avatar
    Join Date
    Oct 2001
    Location
    Chicago, IL
    Posts
    2,514
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: March 22nd, 2007, 09:23 PM
  2. what do these commands do?
    By gigahertz205 in forum Networking and Internet
    Replies: 4
    Last Post: March 7th, 2005, 08:46 PM
  3. Which Commands ?
    By Regulus in forum Applications and Operating Systems
    Replies: 11
    Last Post: October 29th, 2004, 09:13 PM
  4. commands
    By maotx in forum General Tech Discussion
    Replies: 6
    Last Post: June 20th, 2003, 09:07 AM
  5. Linux Commands
    By ridemonkey in forum Webmastering and Programming
    Replies: 6
    Last Post: September 10th, 2002, 10:15 AM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews