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

Whoever 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 doesn’t even require any sign-in, The good thing is that it can accept your lovely nick name also and the URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")

Popular Posts

Enter your email address:

Buffs ...

Tags


Powered by WidgetsForFree