Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell script structure 1

Status
Not open for further replies.
Oct 6, 2002
60
0
0
US
Hi all,

I am just getting into shell scripting (korn) and have noticed that many scripts that include menu's have the menu at the end of the script or that the "main processing" is often at the end of the script. I am more familiar with vba and c++, neither of which typically use this structure. Does anyone have any documentation on this, or could someone provide any insight into the way scripts are executed that may explain the reason scripts are written in this way.

Many thanks,
Ryan
 
man ksh

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi Ryan,

A two or three day "scripting course" would probably only just about answer your questions. Basically a script runs from top to bottom, but doesn't run the functions until they are called (so they can be declared anywhere). It sounds like you are describing a menu (maybe a "case" structure) that calls functions from each option, thus making it easier to read (and debug). I suppose it is an attempt to "modularise" the script.
Personally this is the structure I tend to adopt for scripts. I expect every script writer would have their preferences, this is mine.

Headerblock
Environmental & other variable declarations, etc
Functions
Main body of the script

I hope that helps you.

Mike
 
Thanks to all for replying, it's all starting to come together now, slowly but surely.

Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top