If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > goto in shell script?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-04, 07:50
rei rei is offline
Registered User
 
Join Date: Jul 2004
Posts: 30
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
Reply With Quote
  #2 (permalink)  
Old 07-16-04, 09:24
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On