954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

parameter and labels

I am a novice, so please don't be too technical !
I have written 3 separate scripts which all work OK.
I now need to merge them into one big script.
I would like to introduce a runtime parameter,
to allow me to restart at script2 or script3.
I would prefer not to use functions, as I haven't done the training.
How do I define the labels in the big script ?
And how do I code at the beginning of the big script
to send control to the restart positions ?
Many thanks.

lids05
Newbie Poster
2 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

I do not understand what you intend from your description. It is easy enough to merge the three scripts:

#do the first one
path_to_script_one $parameters_for_script_one
# do the second one
path_to_script_two # maybe this one doesn't need params
# etc


If I guess correctly what you want, you could wrap it all in a loop, and run each of the scripts only if the (label?) is appropriate for that script to be run, then exit from the loop only if the (label?) is a value that indicates it is time to stop.

You could have the individual scripts return a (label?) or you could interact with the user, or maybe something else: Your question was not clear.

griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
 
I am a novice, so please don't be too technical ! I have written 3 separate scripts which all work OK. I now need to merge them into one big script. I would like to introduce a runtime parameter, to allow me to restart at script2 or script3. I would prefer not to use functions, as I haven't done the training.

[indent]
Then it's time you learned, because functions are the only sensible way to do it.

f1() {
 : script 1 here
}

f2() {
 : script 2 here
}

f3() {
 : script 3 here
}

case $1 in
     1) f1 ;;
     2) f2 ;;
     3) f3 ;;
esac

[/indent]How do I define the labels in the big script ?[indent]
There are no labels in shell scripts.
[/indent]

cfajohnson
Junior Poster
196 posts since Dec 2008
Reputation Points: 25
Solved Threads: 23
 

Thanks to both griswolf & cfa.
The need to join the scripts is no longer required, but I will try to implement the above when I am not so busy, as I agree with cfa that I should learn functions.

lids05
Newbie Poster
2 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You