This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Linux / UNIX and the fly likes Passing command line argument in shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Passing command line argument in shell script" Watch "Passing command line argument in shell script" New topic
Author

Passing command line argument in shell script

Himal Chuli
Ranch Hand

Joined: Aug 06, 2002
Posts: 118
hi,
just wondering how could i define a variable in a shell script and pass an argument to it from command line. specifically, i would like to do something like the following:
Script
------------------
myScript(script name)
var
This a var argument passed in command line.
now in command line, typing following
myScript Testing
should display:
This is Testing argument passed in command line.
hope, i have been clear what i would like to do.
appreciate your help.
thanks.
himal


Himal
Blaine Mincey
Greenhorn

Joined: Nov 28, 2000
Posts: 15
Just a quick example....
Command line
$ HelloWorld Blaine
#/bin/bash
VAR_NAME=$1
echo "Hello, $VAR_NAME"
Should result in
$ Hello, Blaine
Remember to make your shell script executable...
Blaine
blaine_mincey@mindspring.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing command line argument in shell script