Problem with DOS paths in perl - cmd.exe vs. command.exe

Discussion in 'Perl Misc' started by Sol Linderstein, Jun 16, 2004.

  1. Hi,

    I've got the following two line perl program that I run on a Windows
    XP Pro system:

    print `c:\\windows\\system32\\cmd.exe /c dir c:\\documents and
    settings\\me\\Desktop` ;

    print `dir c:\\docume~1\\me\\desktop` ;

    When I run it the first line produces an error: The system cannot find
    the file specified. The second line produces the desired output.

    I'm confused because cmd.exe supports spaces in directory paths yet
    it's not supporting them in this perl program.

    Any idea on how I can get perl to do the right thing with backticks
    and paths in DOS?

    Thanks,
    Sol
    Sol Linderstein, Jun 16, 2004
    #1
    1. Advertising

  2. On 16 Jun 2004 10:54:44 -0700, Sol Linderstein <>
    wrote:

    > Hi,
    >
    > I've got the following two line perl program that I run on a Windows
    > XP Pro system:
    >
    > print `c:\\windows\\system32\\cmd.exe /c dir c:\\documents and
    > settings\\me\\Desktop` ;
    >
    > print `dir c:\\docume~1\\me\\desktop` ;
    >
    > When I run it the first line produces an error: The system cannot find
    > the file specified. The second line produces the desired output.
    >
    > I'm confused because cmd.exe supports spaces in directory paths yet
    > it's not supporting them in this perl program.
    >
    > Any idea on how I can get perl to do the right thing with backticks
    > and paths in DOS?
    >
    > Thanks,
    > Sol


    The spaces are the problem nevertheless. Try it with:

    print `c:\\windows\\system32\\cmd.exe /c dir "c:\\dokumente und
    einstellungen\\me\\desktop"`;
    ^^^ german xp
    ;-) ^^^


    --
    Andre

    ---

    Fighting for peace is like f..ing for virginity
    Andre Wisniewski, Jun 16, 2004
    #2
    1. Advertising

  3. Sol Linderstein

    Matt Garrish Guest

    "Purl Gurl" <> wrote in message
    news:...
    > Sol Linderstein wrote:
    >
    > > print `c:\\windows\\system32\\cmd.exe /c dir c:\\documents and

    settings\\me\\Desktop` ;
    >
    > > print `dir c:\\docume~1\\me\\desktop` ;

    >
    > > When I run it the first line produces an error: The system cannot find
    > > the file specified. The second line produces the desired output.

    >


    Why are you calling cmd.exe in the first example? You only need to call dir
    with the file name quoted:

    print `dir "c:\\documents and settings\\me\\Desktop"`;

    >
    > To avoid this problem, never allow spaces in directory names, and
    > always limit both directory names and file names to eight characters
    > plus three for file extensions.
    >


    Prescient advice, twenty years ago...

    >
    > If you are to use MSDOS, you must learn how to use MSDOS.
    >


    If you are to respond to posts, learn how to read the posts. Where did he
    make mention of MS-DOS? He's asking about the command shells in XP. I would
    have thought you'd have figured out the difference by now. Oh wait, no I
    didn't. Never mind...

    Matt
    Matt Garrish, Jun 18, 2004
    #3
  4. Sol Linderstein

    Matt Garrish Guest

    "Purl Gurl" <> wrote in message
    news:...
    >
    > Ignorant illiterate troll.
    >
    > Purl Gurl


    We know what you are...

    Matt
    Matt Garrish, Jun 18, 2004
    #4
    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. Mel
    Replies:
    6
    Views:
    5,654
    William Hamby
    Apr 13, 2005
  2. Achim Domma (Procoders)

    read input for cmd.Cmd from file

    Achim Domma (Procoders), Jun 3, 2005, in forum: Python
    Replies:
    2
    Views:
    8,036
    Peter Otten
    Jun 3, 2005
  3. Sarir Khamsi

    Interpreter-like help in cmd.Cmd

    Sarir Khamsi, Jun 9, 2005, in forum: Python
    Replies:
    4
    Views:
    355
    Bengt Richter
    Jun 26, 2005
  4. Robert Wallace

    my own perl "dos->unix"/"unix->dos"

    Robert Wallace, Jan 21, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    265
    Michele Dondi
    Jan 22, 2004
  5. PerlFAQ Server
    Replies:
    0
    Views:
    242
    PerlFAQ Server
    Apr 26, 2011
Loading...

Share This Page