Unix shell script question (goto - label)

I am a novice shell script programmer, so be gentle!

Currently I have a automated process that uses about 10 separate Bourne shell scripts... One will execute, then fire off the next and so forth.
I want to consolidate the scripts into one, but I need to use some type of "goto" command to a label inside the script. I did not find any "goto" command in my Unix Shell programming book. I know that the "csh" uses "goto", but I was told not to use "csh".

Any suggestions?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you want to merge all the scripts in one piece, define each script as a function of your
main script.
just make sure that you declear the fuction at the beginning of your script


a litter script:

# log something to a log file
echo "$1" >>$LOGFILE 2>&1

Now we, write a main script and modify the above script as a function.


# VAR declarations


# Functions

Log ()
  echo "$1" >>$LOGFILE 2>&1

# start of the main script
# do some thing

# use the function
Log "Subject: SUCCESS!: ${DAY} Backup log for SQL Server"

# do other things



Hope that it can help.

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rlburrisAuthor Commented:
      Please explain (break down) the following command:
echo "$1" >> $LOGFILE 2>&1

Also when you use the function Log in your example... Does "Subject:SUCCESS!" writes to the LOGFILE?

echo "$1" >> $LOGFILE

willl write "Subject: SUCCESS!: ${DAY} Backup log for SQL Server" to $LOGFILE
in this case is /var/log/mylog (I defined it before the function)

echo "$1" >> $LOGFILE 2>&1

will write "Subject: SUCCESS!: ${DAY} Backup log for SQL Server" + any
error message to the login file (I redirect stderr to stdin)
rlburrisAuthor Commented:
Thanks yuzh!!!
You are welcome.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.