Shell script to pass arguments and validation of arguments in side shell

The below is a simple shell script snippet which accepts two kinds of parameters(1. start 2. -start) while running.
How to validate these parameters and how to run the shell script accordingly is the main motto :)
set -x
if [[ "$1" == "start" || "$1" == "-start" ]]; then
echo "code for start action"
else
echo "Please input valid arguments"
echo "Usuage: setup.sh start or setup.sh -start "
exit
fi

Hope this helps in passing parameters to installer like scripts. 
I observed the behavior of the same script differ in different shells like k shell and bash shell.
 

 
 


0 comments to "Shell script to pass arguments and validation of arguments in side shell"

Post a Comment

Who ever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs u can at least use Name/URL option which don’t even require any sign-in, good thing is that it can accept your lovely nick name also and URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")
వీలయితే నాల్గు పోస్టులు ...కుదురితే ఒక కామెంటూ ...

Translate

Enter your email address:

Buffs ...

Visitors


hits counter
View My StatsCheck Google Page Rank

Add to Google Reader or Homepage

Bookmark and Share

Tags


Powered by WidgetsForFree