Perl vs. W2000

  • Thread starter Thread starter Grumpy Aero Guy
  • Start date Start date
G

Grumpy Aero Guy

Here's a shot in the dark for ya:

Given a perl script exists on an XP machine which has perl
installed.....AND, given that I would like to run this script (test.pl) in a
command shell window,

1) The script runs ONLY if you have set default to the directory containing
the (perl) script.

Example: perl script exists in C:\test

I type (in command shell):

c:\ set def test

c:\test> test.pl

It tries to run, the file is "seen"

Assuming c:\test is in the path..... running test.pl from, say, d:>, XP
can't find the file.

i.e., I have tried to copy the script to a folder existing in the path, then
try to run the script when default is set to elsewhere, and it won't run.

2) This perl script takes variables when it is to be executed. In no
circumstance can I get this script to extract variables from the command
line I type when I try to run it.....

Any wisdom out there??

(My employer is getting out of the UNIX world and migrating to
intel/IBM/Windows environment... thus the interest in saving some legacy
functionality when migrating from Unix.)

Thank you in advance.
 
1) Perl scripts can run if they are in a folder that is contained in your
path. There's probably a problem with you path variable. Are you getting
any error messages? A simple test:
make a folder c:\test and copy your script into it. Goto the command prompt
and type:
set path=c:\test
cd \
<run your script (eg test.pl)>

2) There could be a problem with the file association with .pl files. Try
running your script as follows:
perl test.pl <argument 1> <argument 2>

Also, there are subtle differences between Unix Perl and Windows Perl. Most
times this is not an issue but the original programmers could be doing
something Unix specific.
 
<prompt> set def test ?? What's this? If I run it asis I get
"Environment variable not found". If I use
<prompt> set def=test it sets the environment variable "def" to the
value "test".

What's the path to perl and does the script have a hash bang line?

What happens when you run the command so:

<prompt>perl test.pl

Cheers,

Cliff
 
<prompt> set def test ?? What's this?

sorry...typing too fast. What I was trying to communicate was that I set
default to the test directory on c: via the command prompt (e.g., where the
script resides on c)

What's the path to perl and...
I believe it is c:\perl;

....does it have a hash bang line....

No clue what that is...trying to research this for a unix guru not terribly
familiar with Windows who got his workstation pulled out from under him last
week.

What happens when you run the command so:

<prompt>perl test.pl

It runs, so long as you have set default to the directory it (test.pl)
resides in. The minute you do a cd.. to change the default to a directory
different from where the script resides (for example), windows doesn't
recognize the script, eventhough the directory the script resides in is set
in the path.

No matter what he does, it won't take variables from the command line at
all. (He disabled the variables within the script initially to troubleshoot
things one at a time).


???

Thanks for your response.
 
<prompt> set def test ?? What's this?

sorry...typing too fast. What I was trying to communicate was that I set
default to the test directory on c: via the command prompt (e.g., where the
script resides on c)
As in "set default=test" ??? Could you please give the exact command
or a sample?
I believe it is c:\perl;

...does it have a hash bang line....

No clue what that is...trying to research this for a unix guru not terribly
familiar with Windows who got his workstation pulled out from under him last
week.
OK, in a perl script it is normal to have the first line start with:

#!<path to perl>

So if the perl executable is in c:\perl then the hash bang line would
be:

#!C;/perl/perl.exe

I'm not sure about the direction of the "/" in that. It could be
#!C:\perl\perl.exe

It can include parameters to perl (eg -w), but not parameters to the
script.
It runs, so long as you have set default to the directory it (test.pl)
resides in. The minute you do a cd.. to change the default to a directory
different from where the script resides (for example), windows doesn't
recognize the script, eventhough the directory the script resides in is set
in the path.
Can you please "echo %PATH%" at the command prompt, just to check that
this is so, if you haven't already done so.
No matter what he does, it won't take variables from the command line at
all. (He disabled the variables within the script initially to troubleshoot
things one at a time).
That does sound strange.

Cheers,

Cliff
 
Grumpy Aero Guy said:
Given a perl script exists on an XP machine which has perl
installed.....AND, given that I would like to run this script (test.pl) in a
command shell window,
1) The script runs ONLY if you have set default to the directory containing
the (perl) script.
Example: perl script exists in C:\test
I type (in command shell):
c:\ set def test

Okay, I think what you mean here is that you set the current directory
(default doesn't fit in this context) with something like:
C:> CD \test
c:\test> test.pl
It tries to run, the file is "seen"
Assuming c:\test is in the path..... running test.pl from, say, d:>, XP
can't find the file.
i.e., I have tried to copy the script to a folder existing in the path,
then try to run the script when default is set to elsewhere, and it
won't run.

There are two things you need to do in order to execute a script that way
without regard to the current directory. One is to associate the .pl
extension with Perl, which you've apparently done. The other is to append
..PL to the PATHEXT environment variable, which is the list of entensions
which cause Windows to search the path. Mine looks like this:
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PL
 
Back
Top