passing argument not working...
I just installed Perl (v. 5.6.1. built for MSWin32 from ActiveState)
on a new server Windows 2000.
Amazingly the passing of arguments doesn't work !
I saved the following code in a file saved in "test.pl" :
print STDOUT "NbArguments: $#ARGV\n";
print STDOUT "$ARGV, $ARGV\n";
When I call it by "test.pl arg1 arg2", I get:
NbArguments : -1
I ran the same code on 2 other machines (XP and W2000): it works
I also installed another Perl version (INDIGOPERL) on this Server
W2000... and I keep getting the same weird behaviour !
Any idea ??? Does it have to do with the configuration or with
registry entries ?
Thanks for your contribution !
Re: passing argument not working...
The problem has been solved in the meantime...
Surprisingly on this W2000 machine, I need to launch a perl script in
beginning with the command "perl" in order to have the arguments
recognized and passed further:
"perl test.pl arg1 arg2" and not just "test.pl arg1 arg2"
On the other W2000 machine that I have, it isn't necessary to begin
with the "perl" command... Strange, but it works that way!
Have a great day
firstname.lastname@example.org (Romuald Favre) wrote in message news:<email@example.com. com>...
> Hi there,
> I just installed Perl (v. 5.6.1. built for MSWin32 from ActiveState)
> on a new server Windows 2000.
> Amazingly the passing of arguments doesn't work !
> I saved the following code in a file saved in "test.pl" :
> #!/bin/perl -s
> print STDOUT "NbArguments: $#ARGV\n";
> print STDOUT "$ARGV, $ARGV\n";
> When I call it by "test.pl arg1 arg2", I get:
> NbArguments : -1
> I ran the same code on 2 other machines (XP and W2000): it works
> I also installed another Perl version (INDIGOPERL) on this Server
> W2000... and I keep getting the same weird behaviour !
> Any idea ??? Does it have to do with the configuration or with
> registry entries ?
> Thanks for your contribution !
Getting Perl arguments to work in Windows
I believe the following is the answer to why it works on one machine and not the other...
When you setup the file associations for the .pl (or whatever) extension... click on the Advanced button, then Edit the "Open" action. In here you'll see the "Application used to perform this action" field..
When this is first created... it looks like this..
This tells it to pass only the "example.pl" filename into the perl.exe executable..
If you add more variables to this line... such as:
"C:\indigoperl\perl\bin\perl.exe" "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9" "%10"
then windows will forward each of these as well to the perl executable.
For the example above this will ONLY forward 9 command-line entries to your script. Thus, if you need more, then add more.
Now, when you type the following
script.pl one two three four
it get's forwarded into perl.exe as
perl.exe script.pl one two three four
and the ARGV works fine at that point.
Re: Getting Perl arguments to work in Windows
This is all very interesting.
I too am using Windows 2000, and I noticed that sometimes my Perl script can see the command line arguments and sometimes not.
I have a script listargs.pl which lists its command-line arguments (parameters).
I am running Indigo Perl.
It behaves correctly if I type at the command prompt
perl listargs.pl a b c
but it doesn't see them if I just type
listargs.pl a b c
listargs a b c
Either of the latter two find and execute the script because .PL is among the extensions listed in my PATHEXT environment variable, but neither sees the parameters "a b c".
I tried the fix amcq suggested, but when I go to Control Panel / Folder Options / File Types, extension .PL is not listed there. I tried adding it, but it was gone the next time I opened this dialog. So I'm mystified about how Windows knows this is a Perl file...
Any suggestions are welcome.
|All times are GMT. The time now is 07:53 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.