The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Goto last visted directory prasanth_babu SUN Solaris 6 08-11-2008 04:17 AM
Stuck after typing goto rairey UNIX for Dummies Questions & Answers 2 09-20-2007 02:19 PM
goto statement Krrishv Shell Programming and Scripting 5 02-21-2007 07:36 AM
Use of GOTO statement in scripts vikasduhan Shell Programming and Scripting 7 02-02-2006 12:50 PM
Unix version of gosub or goto?? gozer13 Shell Programming and Scripting 3 02-03-2005 11:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-11-2004
Geraldine Geraldine is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 6
how to goto in ksh

Hi,
I'm trying to use the goto in ksh but it does not appear to be a valid command. Is that only valid in csh? Anything similar in ksh that I can use?

Appreciate any help you can provide.

Thanks.

geraldine
  #2 (permalink)  
Old 03-11-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
No goto in ksh. You will need to use structured programming.
  #3 (permalink)  
Old 03-11-2004
Geraldine Geraldine is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 6
Hi,
can someone shed some light on how I can write my own goto statement. I know it's generally not a good idea to use goto but in this circumstances, I think goto would be efficient.

I have a driver script (driverjob.sh) that calls several jobs, eg.

job1
job2
job3
job4
job5

if job3 fails, the driver script will write the name of the job to a log file and stop executing. After the error in job3 is fixed, if I rerun driverjob.sh, I would like the driver script to read from the log file the name of the failed job and process job3 onwards, thus bypassing job1 and job2.
If there is no goto command, the only way I can think of is to use if then else statement and check the status of each job.

Any suggestions?

thanks.

geraldine
  #4 (permalink)  
Old 03-11-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
Try something like:
Code:
[[ -f $LOGFILE ]] && read lastjob <$LOGFILE
for xjob in job1 job2 job3 job4 job5 job6 ; do
       if [[ -z $lastjob || $lastjob = $xjob ]] ; then
            ./$xjob || {echo $xjob > $LOGFILE ; exit 1 ; }
       fi
done

  #5 (permalink)  
Old 03-12-2004
Geraldine Geraldine is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 6
Thanks! That works. I just had to make slight modification to your original script.

thanks again.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0