Tech Support > Operating Systems > Windows 2000 > Perl vs. W2000
Perl vs. W2000
Posted by Grumpy Aero Guy on March 6th, 2004


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.


--


Frank Bachman
(Grumpy Aero Guy)



Posted by GO on March 6th, 2004


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.


"Grumpy Aero Guy" <fbachman@beer_me.com> wrote in message
news:uR4ZBX7AEHA.2600@TK2MSFTNGP09.phx.gbl...


Posted by Enkidu on March 6th, 2004



<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

On Sat, 6 Mar 2004 15:01:00 -0500, "Grumpy Aero Guy"
<fbachman@beer_me.com> wrote:


Posted by Grumpy Aero Guy on March 7th, 2004


<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)



....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.


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.




--


Frank Bachman
(Grumpy Aero Guy)


"Enkidu" <enkidu@xyzcliffpxyz.com> wrote in message
news:iplk40drhbbjc2u0dv58m6knlaq856vesk@4ax.com...


Posted by Enkidu on March 7th, 2004


On Sat, 6 Mar 2004 22:39:37 -0500, "Grumpy Aero Guy"
<fbachman@beer_me.com> wrote:

or a sample?

#!<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.
this is so, if you haven't already done so.

Cheers,

Cliff

Posted by Grumpy Aero Guy on March 7th, 2004


ok...I'll report back tomorrow....something fishy is going on.

--


Frank Bachman
(Grumpy Aero Guy)


"Enkidu" <enkidu@xyzcliffpxyz.com> wrote in message
news:i0cl40h5qr53s93v0ie4ift6ndfvnu1dhf@4ax.com...


Posted by Gary Smith on March 7th, 2004


Grumpy Aero Guy <fbachman@beer_me.com> wrote:

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

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;.WS F;.WSH;.PL

--
Gary L. Smith gls432@yahoo.com
Columbus, Ohio


Similar Posts