Jun
06

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

ANT Automations Awards Banks Batch file Data Structures Database DB2 Devotional Downloads ETV Dhee Feel Fun Games HTML India Java JBOSS Jython Kafka MicroServices Microsoft Mobile Stuff Movies My SQL Networking Oracle Politics Protocols Python Readers choice Reviews Shell Scripting Solaris Springboot Technical Telangana Telugu Tips Travelogues UNIX Web Server Websphere Windows
Powered by WidgetsForFree