#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    1 shell script to run many scripts


    Hello Friends,
    Till date,I didnt get any opportunity to learn about how to write a shell script.But now my work is hectic and the nature of work is to execute a series of OS commands and to run shell scripts in unix environment.

    could some one please help me with a script in which i can add all other scripts that need to be executed .Only after 1 script gets over(as command prompt again appears),the next script( or command) should get executed automatically.could some one help here?

    -
    Bujju
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2006
    Posts
    2,632
    Rep Power
    1811
    It is as simple as listing each script or command in turn, one per line in your 'controlling' script. Purely as an example:

    Code:
    #!/usr/bin/ksh
    
    # One script to rule them, and in the darkness run them ...
    
    # Run each script or command, one at a a time:
    
    /path/to/command/the_command
    /path/to/command/another_command with 3 parameters
    
    # run a command and care about the exit code
    /path/to/command/importand_command
    cmd_exit_code=$?
    if [ $cmd_exit_code -eq 0]
    then
      echo "The import_command command ran ok!"
    else
      echo "important_command failed with an exit code of: $cmd_exit_code"
    fi
    
    # Now run a command and throw away any output
    /path/to/command/noisy_command > /dev/null
    
    # You didn't ask, but let's do it anyway
    # Have the next two commands run 'in batch' so they run at
    # the same time, then wait until both have finished before
    # going on
    /path/to/command/command_a &
    /path/to/command/command_b &
    wait
    
    exit
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0
    Hi Simon,
    I can understand the logic now.You have framed it so beautifully.
    Thanks a lot for that.I am yet to begin my work and was worried a bit.But you have given me hope.Thanks a lot again.

    -
    Bujju
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2006
    Posts
    2,632
    Rep Power
    1811
    Glad to help, if you have any questions .. just ask!
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo