![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| facing problem in starting a process in background using shell script. | dtomar | Shell Programming and Scripting | 8 | 04-17-2008 08:11 AM |
| shell script for extracting out the shortest substring from the given starting and en | pankajd | Shell Programming and Scripting | 18 | 03-10-2008 06:20 AM |
| Trying to manage an inherited Ksh script | ajcannon | Shell Programming and Scripting | 1 | 08-15-2007 06:54 AM |
| Help starting a simple shell script. | dickmartin | Shell Programming and Scripting | 2 | 07-29-2004 09:02 AM |
| How to manage multiple versions of a set of shell and SQL script utilities | DennisB | Shell Programming and Scripting | 2 | 06-23-2004 08:13 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi,
I'd like to run a script with an optional starting point. Meaning that if no parameter for the script => Do everything, otherwise start from the point specified in the parameter and continue till the end. I thought of using the "case ..." but I have no result. Script: # --------------- START_POINT=$1 if [ "$START_POINT" = "" ] then START_POINT="a" fi echo ">$START_POINT<" case $START_POINT in "a") echo "Running >a<!";; "b") echo "Running >b<!";; "c") echo "Running >c<!";; "d") echo "Running >d<!";; default) echo "Wrong value for starting point";; esac return # --------------- result expected: > script [nothing] Running >a<! Running >b<! Running >c<! Running >d<! > script c Running >c<! Running >d<! > script k Wrong value for starting point Please provide some help. Thanks in advance. Regards! |
|
|||||
|
if you are using tcsh, then you can take help of goto to do what you want. bash and ksh does not support goto.
Also, have a look at this (that person might have solved his problem without using goto) Last edited by Yogesh Sawant; 08-29-2007 at 04:24 AM.. Reason: corrected a typo |
|
|||||
|
Put the case-esac construct in a while loop.
Code:
[/tmp]$ cat test.ksh
#! /bin/ksh
#
while :
do
case $1 in
"") set -- a ;;
"a") echo "a" ; set -- b ;;
"b") echo "b" ; set -- c ;;
"c") echo "c" ; set -- d ;;
"d") echo "d" ; break ;;
*) echo "Wrong" ; break ;;
esac
done
[/tmp]$ ./test.ksh
a
b
c
d
[/tmp]$ ./test.ksh a
a
b
c
d
[/tmp]$ ./test.ksh c
c
d
[/tmp]$ ./test.ksh d
d
[/tmp]$ ./test.ksh z
Wrong
[/tmp]$ ./test.ksh abcd
Wrong
[/tmp]$
|
|
||||
|
That's it. Thanks a lot vino .Thanks also to others, I will use some answers for something else .Regards. Antonio. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| shell script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|