Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

path for perl

by manish.rathi (Acolyte)
on Feb 20, 2009 at 00:44 UTC ( #745242=perlquestion: print w/ replies, xml ) Need Help??
manish.rathi has asked for the wisdom of the Perl Monks concerning the following question:

Once I have set path=C:\perl\bin , in environment variable, do I need +to set any other path ? Eventhough this path was set, when I typed "> +perldoc perldoc" on the command line, I was getting error. I put that + error over here and I was suggested to set path as set path=%windir%\system32 set path=%path%;%windir% set path=%path%;%windir%\system32\Wbem set path=%path%;C:\Perl\bin\ what is Wbem and why do I need to set so many paths ? Which is the better way to set path , using environment variable in th +e properties or using "%path%" on the command line. I believe former +one is permanent.

Comment on path for perl
Download Code
Re: path for perl
by Bloodnok (Vicar) on Feb 20, 2009 at 00:51 UTC
    You could have set the path in one line:
    set path=%windir%\system32;%windir%;%windir%\system32\Wbem;C:\Perl\bin +\
    As for Wbem, it's some windoze thing ... as indeed is the requirement for the majority of so many paths

    Which is better ? Hmmm, the answer to that depends on whether, as you yourself suggest, you need the environment to be permanent.

    BTW, you forgot to include the error you were getting when attempting to run perldoc...

    A user level that continues to overstate my experience :-))
      Main question is still answered. When "path=C:\perl\bin" is already s +et in the environment variable, why do I get such an error. Why do I +need to set other path as asked in the post Here is the error I get C:\perlfiles>perldoc perldoc Can't spawn "cmd.exe": No such file or directory at C:/Perl/lib/Pod/Pe +rldoc.pm l ine 1515. Can't spawn "cmd.exe": No such file or directory at C:/Perl/lib/Pod/Pe +rldoc.pm l ine 1515. Can't spawn "cmd.exe": No such file or directory at C:/Perl/lib/Pod/Pe +rldoc.pm l ine 1515.
        Try using the file search in Windoze Explorer (or as I know it, Exploder:-) to search for cmd.exe - having found it, add the directory in which it's located to the path - probably somewhere near the front.

        .oO(It [cmd.exe] might even 'live' in %windir%\system...)

        A user level that continues to overstate my experience :-))

        Just an Off Topic note about readability: <p></p> are for paragraphs (text), <c></c> tags are for code/error reporting. When you surround your whole node in <c></c> tags the paragraph portions become harder to read.

        And you didn't even know bears could type.

        You get that error because the perldoc script uses the 'more' command of the DOS command line shell (cmd.exe) to show you the perldoc. So cmd.exe has to be in the PATH too as well as any other program perldoc might need.

        I don't know much about perl or shells on windows, but you might check if PATH (or path) already has a nice collection of paths before you overwrite it with 'path=...', so you might check that and just add the perl path to it instead of overwriting

        Something's very wrong if cmd.exe isn't in the PATH. It should be in %windir%\system32. Either the PATH in effect isn't what you think it is, or your Windows install is broken.
Re: path for perl
by Anonymous Monk on Feb 20, 2009 at 07:30 UTC
    Once I have set path=C:\perl\bin , in environment variable, do I need to set any other path ?
    Like you were already told, setting path to C:\perl\bin was a mistake. %PATH% is not empty, and you cannot replace it with C:\perl\bin, you can however add C:\perl\bin to the path, which is what you should have done.

      Sorry about that improper wordings. Actually C:\perl\bin is added to PATH. Here is the result of "set path"

      "C:\perlfiles>set path PATH=C:\Perl\bin;C:\Program Files\java\jdk1.6.0_11\jre\bin;C:\Program Files\DivX \DivX Player\DivX Player.exe; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH"

      Question is when cmd.exe is already set in environment variable "ComSpec", why is it not found by "perldoc" ? Is it supposed to be set in any other environment variable ? If thats the case, then whenever any program is using cmd.exe, it will give the same error, right ?

        Question is when cmd.exe is already set in environment variable "ComSpec", why is it not found by "perldoc" ?

        Because "cmd.exe" is only the local name of the file. All versions of the Microsoft file systems also need to know which directory "cmd.exe" resides in. That is the function of %PATH%: to list all the directories where the OS should look when it has only the local name.

        The value of %PATH% you show appears to be missing the directory where cmd.exe is located. For example, in Vista cmd.exe is located in the C:\Windows\System32 directory. I think this is also true for all of the 32 bit versions of Windows (e.g. 95, 2000, XP), but others can verify this.

        The long ugly list of directories that the first few posters said needed to be in PATH are also missing from you %PATH%. They hold not only cmd.exe but several system libraries (DLLs). Many compiled programs only have the local name of the libraries they want and so the MS OSes rely on PATH to find the directory where those libraries are located.

        Paths are searched in the same order they are listed so you'll also want those directories to be the first one's on the path. Otherwise, the OS might find first (and use) a program that just happens to be named "cmd.exe" that isn't the one provided by the OS. Once you've added these directories to your path, things should probably work OK.

        It may not make sense that Windows doesn't just "know" where these things are located, but that's the way it is.

        Best, beth

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://745242]
Approved by Bloodnok
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-10-31 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (215 votes), past polls