[Newbie] Running a Perl script on Windows

Discussion in 'Perl Misc' started by Juergen Fenn, Oct 8, 2005.

  1. Juergen Fenn

    Juergen Fenn Guest

    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.
     
    Juergen Fenn, Oct 8, 2005
    #1
    1. Advertising

  2. Juergen Fenn

    Juergen Fenn Guest

    Purl Gurl <> 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! :cool:

    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.
     
    Juergen Fenn, Oct 8, 2005
    #2
    1. Advertising

  3. Juergen Fenn

    Matt Garrish Guest

    "Purl Gurl" <> wrote in message
    news:...
    > 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
     
    Matt Garrish, Oct 8, 2005
    #3
  4. Juergen Fenn

    Matt Garrish Guest

    "Juergen Fenn" <> wrote in message
    news:...
    > Purl Gurl <> 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
     
    Matt Garrish, Oct 8, 2005
    #4
  5. Juergen Fenn <> wrote in news::

    > Purl Gurl <> 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 <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 8, 2005
    #5
  6. Juergen Fenn

    Matt Garrish Guest

    "A. Sinan Unur" <> wrote in message
    news:Xns96E9AF59A1CAasu1cornelledu@127.0.0.1...
    > Juergen Fenn <> wrote in news::
    >
    >> Purl Gurl <> 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
     
    Matt Garrish, Oct 8, 2005
    #6
  7. Juergen Fenn

    Matt Garrish Guest

    "Matt Garrish" <> wrote in message
    news:aCW1f.6804$...
    >
    > "Juergen Fenn" <> wrote in message
    > news:...
    >> Purl Gurl <> 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
     
    Matt Garrish, Oct 8, 2005
    #7
  8. Juergen Fenn

    Juergen Fenn Guest

    "Matt Garrish" <> 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.
     
    Juergen Fenn, Oct 9, 2005
    #8
  9. Juergen Fenn

    Juergen Fenn Guest

    "Matt Garrish" <> 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. :cool: Thanks a lot for helping me. This is what I
    was looking for.

    Thanks!
    Juergen.
     
    Juergen Fenn, Oct 9, 2005
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,813
  2. Pea
    Replies:
    8
    Views:
    149
    Tad McClellan
    Jan 21, 2004
  3. Stephen M
    Replies:
    2
    Views:
    105
    Stephen M
    Apr 16, 2004
  4. Replies:
    4
    Views:
    189
    Josef Moellers
    Oct 27, 2007
  5. Replies:
    4
    Views:
    297
    ccc31807
    Jul 29, 2011
Loading...

Share This Page