WebSphere Issues

04/09/2010

Linux shell scripting basics

Filed under: Linux — Ishtiaque @ 9:40 am

1. Following  example will execute the script while passing argument to it:

./test.sh value1 value2

echo Script name $0     # $0 will contains script name

ARG1=$1

ARG2=$2

echo you entered $ARG1 and $ARG2

2. Following example will get argument at command prompt:

read USER

echo You entered $USER

3. Following example will verify number of arguments:

if [ $# != 2 ]

then

echo Please enter username and password

exit

fi

Note: There should be space b/w “[” and variable. Also “then” keyword should be placed no second line.

References:

a. http://www.ibm.com/developerworks/library/l-bash2.html

b. http://www.linuxconfig.org/Bash_scripting_Tutorial

c. http://linuxhelp.blogspot.com/2005/10/10-seconds-guide-to-bash-shell.html

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: