CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
Passing args in command line

 



monocle
User

Sep 28, 2000, 4:01 PM

Post #1 of 4 (2697 views)
Passing args in command line Can't Post

I am running an NT box with ActivePerl on SambarServer 4.1.

I have a script that accepts form input and then does some stuff. It works perfect through the browser.

However, I have a need now to run this script from the command prompt (actually as a scheduled task but one step at a time). I am trying to run the script from the command prompt and pass it the argument it would get from the form but I can't get the command line right. If I don't pass it an argument, the script runs fine. But everything I've tried to pass in a parameter fails. Can anyone tell me what the proper syntax should be? And perhaps how to read the arguments inside the script? I am just using the same code that it used when running through the browser.

Thanks,


------------------
Monocle
Hear great techno music by Monocle at http://www.mp3.com/monocle. CD now on sale!



brian.hayes
User

Sep 28, 2000, 4:45 PM

Post #2 of 4 (2697 views)
Re: Passing args in command line [In reply to] Can't Post

Your script will not run via command prompt without changing the way it gets your params. Try using ARVG[] when running scripts from a command line.

Example:
myperl.pl first Second Third

Code:
my first = ARGV[1];
my Second = ARGV[2];
my Third = ARGV[3];

Brian Hayes www.eallowed.com


Kanji
User

Sep 29, 2000, 2:08 AM

Post #3 of 4 (2697 views)
Re: Passing args in command line [In reply to] Can't Post

If you're using CGI.pm, then you want ...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

script.cgi "var=something" "another_var=something else"</pre><HR></BLOCKQUOTE>

... which CGI.pm will automatically convert into param('var'), etc. for you so that you don't have to work out how args are getting in.


monocle
User

Sep 29, 2000, 7:33 AM

Post #4 of 4 (2697 views)
Re: Passing args in command line [In reply to] Can't Post

Thanks guys,

Kanji - could not get yours to work but thanks.

Brian - got yours to work but had to make a few tweeks. they are noted in bold

Example:
myperl.pl first Second Third

Code:
my first = $ARGV[0];
my Second = $ARGV[1];
my Third = $ARGV[2];

thanks again


------------------
Monocle
Hear great techno music by Monocle at http://www.mp3.com/monocle. CD now on sale!


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives