How to make perl script executable from anywhere on windows?

Discussion in 'Perl Misc' started by veg_all@yahoo.com, Apr 20, 2007.

  1. Guest

    I have ActivePerl installed and want to place all my scripts in one
    directory but be able to execute them from anywhere. So if I type perl
    myscript.pl from any directory/folder in windows dos prompt it will
    run.
    , Apr 20, 2007
    #1
    1. Advertising

  2. wrote:
    > I have ActivePerl installed and want to place all my scripts in one
    > directory but be able to execute them from anywhere. So if I type perl
    > myscript.pl from any directory/folder in windows dos prompt it will
    > run.
    >


    Add the directory which contains your scripts to the PATH variable.

    For example, if you have scripts x.pl, y.pl and z.pl in
    C:\My\Perl\Scripts you can type these commands from any directory

    D:\Temp> PATH=%PATH%;C:\My\Perl\Scripts
    D:\Temp> x.pl
    D:\Temp> cd \Other
    D:\Other> x.pl

    You can make the PATH change permanent as follows:
    # From the desktop, right click My Computer and click properties.
    # In the System Properties window, click on the Advanced tab.
    # In the Advanced section, click the Environment Variables button.
    # Finally, in the Environment Variables window, highlight the path
    variable in the Systems Variable section and click edit. Add or modify
    the path lines with the paths you wish the computer to access. Each
    different directory is separated with a semicolon

    Note that this has *nothing* to do with perl.exe being on the path or
    file associations for .pl. The ActiveState installer will already have
    taken care of both of these. I think the other responder has
    misunderstood your question.
    RedGrittyBrick, Apr 20, 2007
    #2
    1. Advertising

  3. >> veg_all wrote:
    >>> I have ActivePerl installed and want to place all my scripts in one
    >>> directory but be able to execute them from anywhere. So if I type perl
    >>> myscript.pl from any directory/folder in windows dos prompt it will
    >>> run


    Which is a question about how to execute d:\my\onedirectory\myscript.pl
    by typing `perl myscript.pl` when the current directory is c:\elsewhere.

    The answer is to add d:\my\onedirectory to your path and type the
    command `myscript.pl`.

    The answer is *not* to associate the .pl filename extension with
    perl.exe - the installer will already have done this.


    > Purl Gurl previously wrote:
    >>

    http://aspn.activestate.com/ASPN/do...Winfaq4.html#How_do_I_associate_Perl_scripts_

    Which is a document about how to associate the .pl filename extension
    with the perl interpreter.

    Associating pl with perl.exe does not help the OP achieve success with
    c:\elsewhere> perl myscript.pl
    when myscript.pl is in d:\my\onedirectory
    which is what he said he wants to do.

    >> http://radio.weblogs.com/0100529/WinXp/


    Also about "Associate file types on the command line"


    > RedGrittyBrick wrote:
    >> Add the directory which contains your scripts to the PATH variable.

    <exact instructions snipped>

    Which *will* help the OP achieve success with
    c:\elsewhere> perl myscript.pl
    when myscript.pl is in d:\my\onedirectory
    which is what he said he wants to do.

    Note that my advice
    >> Add the directory which contains your scripts to the PATH variable.

    Is *not* the same as PurlGurl's advice to associate the .pl filename
    extension with the perl interpreter.

    In my original response I added
    >> Note that this has *nothing* to do with perl.exe being on the path or
    >> file associations for .pl. The ActiveState installer will already have
    >> taken care of both of these. I think the other responder has
    >> misunderstood your question.


    PurlGurl then wrote:
    >
    > I am curious.
    >
    > I provide the precise same information as you,


    No you didn't.


    > With your having repeated what I wrote, but to a significantly
    > lesser degree of quality,


    My advice was completely different.


    > why do you understand and I misunderstand?


    Because I read the original posting more carefully.


    > Appears you are lying to readers just as McClellan lies to readers.


    It is not a lie to say that associating the .pl filename extension with
    the perl interpreter does not enable you to run a perl program by typing
    `perl myscript.pl` when myscript.pl is not in the current directory.

    Especially when the ActivePerl installer will already have made that
    association.
    RedGrittyBrick, Apr 21, 2007
    #3
    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. Wet Basement
    Replies:
    1
    Views:
    2,517
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,792
  3. Replies:
    15
    Views:
    486
    Dave Thompson
    Aug 21, 2006
  4. pratap
    Replies:
    20
    Views:
    758
    Flash Gordon
    Mar 7, 2007
  5. Harry
    Replies:
    26
    Views:
    385
    MSwanberg
    Sep 21, 2009
Loading...

Share This Page