Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [Newbie] Running a Perl script on Windows

Reply
Thread Tools

[Newbie] Running a Perl script on Windows

 
 
Juergen Fenn
Guest
Posts: n/a
 
      10-08-2005
Hello,

I am new to Perl so would you please apologise if this is an FAQ I
didn't read about earlier. I have the Lama Book here and I have had a
look into the ActivePerl FAQs, but I can't find anything about it. I
probably don't know the correct term to search for.

This is my question:

I have tried to use html2latex with ActivePerl 5.8.0 on my Windows 98
system recently. It works well when I put the script in the same
directory as the HTML file to be processed by the script. I call the
script using "perl html2latex myfile.html" from that same directory.

Now I put it in a directory that is in my PATH for further usage. It
doesn't work.
Perl does not find the script.
However, _I_ can find the script when I enter "which html2latex".

But where exactly does Perl look for scripts?

I tried to put the file in one of the directories other than "." that
are in @INC, but this didn't work either...

Do I have to write a DOS batch file for running Perl scripts that are
in my PATH?

Thanks in advance!
Juergen.
 
Reply With Quote
 
 
 
 
Juergen Fenn
Guest
Posts: n/a
 
      10-08-2005
Purl Gurl <(E-Mail Removed)> writes:

>> perl c:/your/path/to/html2latex myfile.html

>
>> When you call an executable outside your current
>> working directory, you must provide a full path
>> or issue a "change directory" command to the
>> directory containing your executable.

>
> Expanding on this, if your to use your latex program
> frequently, you can modify your Win98 autoexec.bat
> to automatically include a path which can be used in
> any directory, you only need to issue,
>
> html2latex
>
> for any given directory when a parent path is set in
> your environment variables through an autoexec.bat file.


Thanks for answering. Now, this is exactly what I tried before. I
saved html2latex in a directory that is in the PATH set in my
autoexec.bat. This works with exe and bat files, as you wrote, but it
does not work with a Perl script here:

D:\Dateien\temp>perl html2latex.pl myfile.htm
Can't open perl script "html2latex.pl": No such file or directory

Renaming the script to exe/ bat, as you suggested, does not work
either.

Only using full paths both to html2latex as well as to the HTML file
to convert has solved the problem. Thanks for your advice!

However, the question remains why does Perl on Windows not find the
script in my PATH?

html2latex contains a readme file for use on MS Windows suggesting
this should be the case:

You can put html2latex anywhere you want. Putting in your path makes
command-line usage very easy, however.

Thanks!
Juergen.
 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      10-08-2005

"Purl Gurl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Juergen Fenn wrote:
>
>> I have tried to use html2latex with ActivePerl 5.8.0 on my Windows 98
>> system recently. It works well when I put the script in the same
>> directory as the HTML file to be processed by the script. I call the
>> script using "perl html2latex myfile.html" from that same directory.

>
> (snipped)
>
>
> perl c:/your/path/to/html2latex myfile.html
>
> A presumption is made "html2latex" has an executable
> extension such as ".exe" or ".bat" so DOS can run it.
>


Why would you call the perl interpreter on a file that is actually an
executable or batch file? Did you get confused between typing your command
and writing the explanation?

Matt


 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      10-08-2005

"Juergen Fenn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Purl Gurl <(E-Mail Removed)> writes:
>
>>> perl c:/your/path/to/html2latex myfile.html

>>
>>> When you call an executable outside your current
>>> working directory, you must provide a full path
>>> or issue a "change directory" command to the
>>> directory containing your executable.

>>
>> Expanding on this, if your to use your latex program
>> frequently, you can modify your Win98 autoexec.bat
>> to automatically include a path which can be used in
>> any directory, you only need to issue,
>>
>> html2latex
>>
>> for any given directory when a parent path is set in
>> your environment variables through an autoexec.bat file.

>
> Thanks for answering. Now, this is exactly what I tried before. I
> saved html2latex in a directory that is in the PATH set in my
> autoexec.bat. This works with exe and bat files, as you wrote, but it
> does not work with a Perl script here:
>
> D:\Dateien\temp>perl html2latex.pl myfile.htm
> Can't open perl script "html2latex.pl": No such file or directory
>
> Renaming the script to exe/ bat, as you suggested, does not work
> either.
>


Her advice is usually wrong. Your problem is that you're invoking the
interpreter to call the script, and the interpreter does not care what
system paths you have specified. You must call your script with an absolute
or relative path if it is not in the same directory where you're trying to
invoke it. Otherwise, perl will look for that file in the current directory.
You can change your path all you want, but that's just fact of life.

XP improved on the command line by making file associations available.
Consequently, you could type:

html2latex.pl myfile.htm

under XP and the file will be run so long as it is somewhere in your path.
If you explicitly call the interpreter, however:

perl html2latex.pl myfile.htm

you will get the same problem you're encountering on Win98.

Matt


 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      10-08-2005
Juergen Fenn <(E-Mail Removed)> wrote in news:(E-Mail Removed):

> Purl Gurl <(E-Mail Removed)> writes:


....

> Thanks!
> Juergen.


Please read <URL:http://tinyurl.com/8rnfl>

(it's just a canned Google Groups search which for the benefit of all
those who have only recently started following the group).

Sinan

--
A. Sinan Unur <(E-Mail Removed)>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      10-08-2005

"A. Sinan Unur" <(E-Mail Removed)> wrote in message
news:Xns96E9AF59A1CAasu1cornelledu@127.0.0.1...
> Juergen Fenn <(E-Mail Removed)> wrote in news:(E-Mail Removed):
>
>> Purl Gurl <(E-Mail Removed)> writes:

>
> ...
>
>> Thanks!
>> Juergen.

>
> Please read <URL:http://tinyurl.com/8rnfl>
>
> (it's just a canned Google Groups search which for the benefit of all
> those who have only recently started following the group).
>


This one really says all that will ever need to be said:

http://tinyurl.com/73eeo

Matt


 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      10-08-2005

"Matt Garrish" <(E-Mail Removed)> wrote in message
news:aCW1f.6804$(E-Mail Removed)...
>
> "Juergen Fenn" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Purl Gurl <(E-Mail Removed)> writes:
>>
>>>> perl c:/your/path/to/html2latex myfile.html
>>>
>>>> When you call an executable outside your current
>>>> working directory, you must provide a full path
>>>> or issue a "change directory" command to the
>>>> directory containing your executable.
>>>
>>> Expanding on this, if your to use your latex program
>>> frequently, you can modify your Win98 autoexec.bat
>>> to automatically include a path which can be used in
>>> any directory, you only need to issue,
>>>
>>> html2latex
>>>
>>> for any given directory when a parent path is set in
>>> your environment variables through an autoexec.bat file.

>>
>> Thanks for answering. Now, this is exactly what I tried before. I
>> saved html2latex in a directory that is in the PATH set in my
>> autoexec.bat. This works with exe and bat files, as you wrote, but it
>> does not work with a Perl script here:
>>
>> D:\Dateien\temp>perl html2latex.pl myfile.htm
>> Can't open perl script "html2latex.pl": No such file or directory
>>
>> Renaming the script to exe/ bat, as you suggested, does not work
>> either.
>>

>
> Her advice is usually wrong. Your problem is that you're invoking the
> interpreter to call the script, and the interpreter does not care what
> system paths you have specified. You must call your script with an
> absolute or relative path if it is not in the same directory where you're
> trying to invoke it. Otherwise, perl will look for that file in the
> current directory. You can change your path all you want, but that's just
> fact of life.
>


My bad, actually. I wasn't even thinking about the -S switch as I haven't
run a Win98 box in years. You might try:

perl -S html2latex.pl myfile.html

I can't guarantee it will work on win98, not having a box to test on, but it
should...

Matt


 
Reply With Quote
 
Juergen Fenn
Guest
Posts: n/a
 
      10-08-2005
"Matt Garrish" <(E-Mail Removed)> writes:

> This one really says all that will ever need to be said:
>
> http://tinyurl.com/73eeo


I've got a killfile and I know how to use it.

THX.
Juergen.
 
Reply With Quote
 
Juergen Fenn
Guest
Posts: n/a
 
      10-08-2005
"Matt Garrish" <(E-Mail Removed)> writes:

> perl -S html2latex.pl myfile.html
>
> I can't guarantee it will work on win98, not having a box to test on, but it
> should...


It does work indeed. Thanks a lot for helping me. This is what I
was looking for.

Thanks!
Juergen.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble running Perl script from within a Perl script laredotornado@zipmail.com Perl Misc 4 07-29-2011 01:44 PM
How to fetch output of some other script in the current running perl script? ritugoyal12@gmail.com Perl Misc 4 10-27-2007 03:52 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments