Computing.Net > Forums > Unix > Unix Script ignoring cmd line vars

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix Script ignoring cmd line vars

Reply to Message Icon

Name: bluesman73
Date: April 27, 2004 at 12:13:28 Pacific
OS: aix
CPU/Ram: pseries server 2 gb ram
Comment:

I'm getting a little frustrated and would appreciate any help.

I'm writting a unix script, and no matter what I do, it ignores the command line variables. At this point, I'm just trying to echo out what the value is to prove that it is coming in.

The script is:


# check input parameters
echo $0
echo $1
echo $2
echo $3
echo $#
echo $*

I run it by typing it:
./run_it 1 2 3

and the output is:

./run_it


0


Any ideas?

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Wolfbone
Date: April 27, 2004 at 12:59:12 Pacific
Reply:

Could it be you need the #!/bin/some_shell line at the top?


0

Response Number 2
Name: bluesman73
Date: April 27, 2004 at 13:59:35 Pacific
Reply:

Well, I'm a noob, but I added in the line indicating what shell i'm using
#!/bin/ksh

it didn't work at first. I then started typing fast and furious, trying different combinations of, basically:
/bin/ksh ./run_it 1 2

and it didn't work at first..but then suddenly it did work. The only problem is, I didn't pay attention to what I was typing and closed the window. So I've another newbie question:

If you were to invoke this script in the korn shell, how would you do it?


0

Response Number 3
Name: Wolfbone
Date: April 27, 2004 at 14:52:51 Pacific
Reply:

Just as you have done!

1) write the script, putting magic string in the first line

2) $> chmod +x script_file

3) $> ./script_file arg1 arg2 ... argn

I can't see what could be wrong. The only other thing I can think of is that some OSes don't recognise #!/bin/ksh - they need a space: #! /bin/ksh. You could look for some scripts in the systemwide /bins that take arguments and see if they are working properly.


0

Response Number 4
Name: Wolfbone
Date: April 27, 2004 at 14:58:35 Pacific
Reply:

Just had another thought - try print instead of echo.


0

Response Number 5
Name: bluesman73
Date: April 28, 2004 at 06:56:52 Pacific
Reply:

Thanks for the help.

Neither made any different. I think something quarky is going on. I'm going to skip this issue and move on.

Thanks again.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix Script ignoring cmd line vars

Unix script line - means what?? www.computing.net/answers/unix/unix-script-line-means-what/5981.html

Unix Script - simple question pleas www.computing.net/answers/unix/unix-script-simple-question-pleas/3792.html

Need kindly help about UNIX script! www.computing.net/answers/unix/need-kindly-help-about-unix-script/5562.html