Problem passing arguments in WindowsXP

S

stocksami

I had no problems with Windows2000 but now I'm using a PC with XP. The
problem is that perl scripts don't receive argurments if I type
"myscript.pl a b c". If I type "perl myscript.pl a b c" the arguments
are received. That is not a viable solution, though, since I need to
call some perl scripts from within a compiled program and I don't want
to be to modify the calling program to do that.

I read another message suggesting using ftype to see how perl is run
and to associate arguements with my script. "ftype perl" returns:
perl=c:\Perl\bin\perl.exe %1 %*

If I type "ftype myscript.pl=C:\Perl\bin\perl.exe %1 %*" and the type
"ftype myscript" it returns
myscript.pl=c:\Perl\bin\perl.exe %1 %*

It still doesn't work, though. Is there a solution to this problem
other than telling Bill Gates to go to H**** and only using unix?

Clark
 
A

A. Sinan Unur

(e-mail address removed) wrote in
I had no problems with Windows2000 but now I'm using a PC with XP.
The problem is that perl scripts don't receive argurments if I type
"myscript.pl a b c". If I type "perl myscript.pl a b c" the arguments
are received. That is not a viable solution, though, since I need to
call some perl scripts from within a compiled program and I don't want
to be to modify the calling program to do that.

I read another message suggesting using ftype to see how perl is run
and to associate arguements with my script. "ftype perl" returns:
perl=c:\Perl\bin\perl.exe %1 %*

C:\opt\psdk> ftype perl
perl="C:\opt\Perl\bin\perl.exe" "%1" %*
If I type "ftype myscript.pl=C:\Perl\bin\perl.exe %1 %*" and the type
"ftype myscript" it returns
myscript.pl=c:\Perl\bin\perl.exe %1 %*

That is nonsense.
It still doesn't work, though. Is there a solution to this problem
other than telling Bill Gates to go to H**** and only using unix?

This has nothing to do with Bill Gates. I have never had any problems
with the stock ActiveState Perl installation on anything from Win 98 to
Win XP. It seems to me that you changed settings in classic slapstick
manner.

C:\opt\psdk> ftype /?
Displays or modifies file types used in file extension associations

FTYPE [fileType[=[openCommandString]]]

fileType Specifies the file type to examine or change
openCommandString Specifies the open command to use when launching
files
of this type.

Type FTYPE without parameters to display the current file types that
have open command strings defined. FTYPE is invoked with just a file
type, it displays the current open command string for that file type.
Specify nothing for the open command string and the FTYPE command will
delete the open command string for the file type. Within an open
command string %0 or %1 are substituted with the file name being
launched through the assocation. %* gets all the parameters and %2
gets the 1st parameter, %3 the second, etc. %~n gets all the remaining
parameters starting with the nth parameter, where n may be between 2 and
9,
inclusive. For example:

ASSOC .pl=PerlScript
FTYPE PerlScript=perl.exe %1 %*

would allow you to invoke a Perl script as follows:

script.pl 1 2 3

If you want to eliminate the need to type the extensions, then do the
following:

set PATHEXT=.pl;%PATHEXT%

and the script could be invoked as follows:

script 1 2 3
 
M

MSG

I had no problems with Windows2000 but now I'm using a PC with XP. The
problem is that perl scripts don't receive argurments if I type
"myscript.pl a b c". If I type "perl myscript.pl a b c" the arguments
are received. That is not a viable solution, though, since I need to
call some perl scripts from within a compiled program and I don't want
to be to modify the calling program to do that.

I read another message suggesting using ftype to see how perl is run
and to associate arguements with my script. "ftype perl" returns:
perl=c:\Perl\bin\perl.exe %1 %*

If I type "ftype myscript.pl=C:\Perl\bin\perl.exe %1 %*" and the type
"ftype myscript" it returns
myscript.pl=c:\Perl\bin\perl.exe %1 %*

It still doesn't work, though. Is there a solution to this problem
other than telling Bill Gates to go to H**** and only using unix?

Clark

Uninstall and then reinstall perl in Windows. That should fix it.
 
S

stocksami

That works fine on my home PC but not on the PC at work. Everything
looks the same, including the response from ftype perl, it just doesn't
work. We have centrally administered PCs and something is different.
I just haven't been able to figure what is going on.

Clark
 
S

stocksami

Please excuse the lack of quoting in my previous post. I'm using
Google and I didn't realize how it handled replies until now. I was
replying to Sinan's post where he talked about the ftype function. My
problem is that I can't pass arguments to a perl function unless I
preface the command with perl

perl myscript.pl a b # works
myscript a b # doesn't work
 
H

Harry331

(e-mail address removed) wrote...
perl myscript.pl a b # works
myscript a b # doesn't work

On *nix, if your_perl_script is shebanged with
#!/path/to/perl

running /path/to/your_perl_script will invoke perl
to interpret and execute your_perl_script.

On WindowsXP, you cannot expect this shebang stuff to work
because <fill in the reasons why you dislike Windows here>.

So, on WindowsXP,
perl myscript.pl a b # works
myscript a b # doesn't work

are AS_DESIGN.

I don't see any problem here.
 
A

A. Sinan Unur

(e-mail address removed)_ (Harry331) wrote in @pd7tw2no:
(e-mail address removed) wrote...


On *nix, if your_perl_script is shebanged with
#!/path/to/perl

running /path/to/your_perl_script will invoke perl
to interpret and execute your_perl_script.

On WindowsXP, you cannot expect this shebang stuff to work
because <fill in the reasons why you dislike Windows here>.

Well, while the shebang line is not used to find the interpreter on XP,
the OP's expectations are completely OK. On a properly set up XP
installation (perl is in the PATH variable, and PATHEXT is set up to
recognize .pl and/or .plx as an executable extension), typing myscript
will invoke the script. The arguments will also be passed to the script
by the shell.

As I mentioned before, I do not know the answer to the OP's question,
but your answer is wrong.
So, on WindowsXP,

are AS_DESIGN.
No.

I don't see any problem here.

Still, there is a problem.

Sinan
 
S

stocksami

Harry331 said:
(e-mail address removed) wrote...


On *nix, if your_perl_script is shebanged with
#!/path/to/perl

running /path/to/your_perl_script will invoke perl
to interpret and execute your_perl_script.

On WindowsXP, you cannot expect this shebang stuff to work
because <fill in the reasons why you dislike Windows here>.

So, on WindowsXP,

are AS_DESIGN.

I don't see any problem here.

This should work on a PC as Sinan explained in his reply. It works on
my home PC and it also worked on my work PC before I was given an XP PC
to replace the Windows2K machine that I had previously.

There is something odd about my work PC. It is centrally administered
and uses a customized version of WindowsXp.

Clark
 
L

l v

(e-mail address removed) wrote:

One thing that I noticed is that Sinans has double-quotes around the
%1, yours does not. My XP Home and Win2k servers all have the
double-quotes.
From Sinan's post
perl="C:\opt\Perl\bin\perl.exe" "%1" %*
From your's
myscript.pl=c:\Perl\bin\perl.exe %1 %*

Additionally, note that Sinan is using ftype perl, you are using ftype
myscript. I think ftype myscript.pl is configured wrong. Based on your
ftype output:
perl myscript.pl a b # works
is the same as typing c:\Perl\bin\perl.exe myscript.pl a b
while this is typeing c:\Perl\bin\perl.exe a b
Note that you are missing the perl program name.

In many cases I convert my Perl scripts into batch files using pl2bat
myscript.pl, then I only have to type myscript a b without registry
updates. Perhaps pl2bat will work for your situation.


[snip]
This should work on a PC as Sinan explained in his reply. It works on
my home PC and it also worked on my work PC before I was given an XP PC
to replace the Windows2K machine that I had previously.
There is something odd about my work PC. It is centrally administered
and uses a customized version of WindowsXp.

Perhaps it incorrectly centrally administered.

Len
 
A

A. Sinan Unur

(e-mail address removed) wrote:

One thing that I noticed is that Sinans has double-quotes around the
%1, yours does not. My XP Home and Win2k servers all have the
double-quotes.

perl="C:\opt\Perl\bin\perl.exe" "%1" %*

myscript.pl=c:\Perl\bin\perl.exe %1 %*

That discrepancy, among other things, was what I was trying to point out
in my response. I assumed the OP had alrwady fixed those issues by the
time he posted his response. If not, he should.

Sinan
 
H

Harry

Please excuse the lack of quoting in my previous post. I'm using
Google and I didn't realize how it handled replies until now. I was
replying to Sinan's post where he talked about the ftype function. My
problem is that I can't pass arguments to a perl function unless I
preface the command with perl

perl myscript.pl a b # works
myscript a b # doesn't work

This posting is misleading by itself (without mentioning your file
association settings.)

When I read this posting at home from my ISP's newsserver, I couldn't
see any previous posting from Sinan. Nor did I see any mentioning on
file association setting on your posting here.

Please quote enough stuff.
 
S

stocksami

A. Sinan Unur said:
That discrepancy, among other things, was what I was trying to point out
in my response. I assumed the OP had alrwady fixed those issues by the
time he posted his response. If not, he should.

Sinan

Yes I did indeed correct those discrepancies.

Clark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top