Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    30

    Unanswered: goto in shell script?

    i have a group of commands to be executed in a shell script
    (each group has a lists of commands)
    if any commands failed, program will be terminated.

    i want to code my shell script, so that the next time it restarts, it will start from the point of group where it is terminated.

    let's say i gave a number to every group.

    so, next time when i start the script, i can give the process number as arguments to the shell script.

    ./myshell.sh 3 <-- starts from no 3 group

    by default, it starts from the beginning.

    may i know in what way i can write this?
    how to give number to each group?
    any tutorial help with example?

    thanks

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Try this:

    Code:
    #!/bin/ksh
    restart=${1:-0}
    if [ restart -eq 0 ]
    then
      echo "Starting at the top"
      ...
      (( restart += 1 ))
    fi
    if [ restart -eq 1 ]
    then
      echo "Starting at $restart"
      ...
      (( restart += 1 ))
    fi
    if [ restart -eq 2 ]
    then
      echo "Starting at $restart"
      ...
      (( restart += 1 ))
    fi
    ... etc ...
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •