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

S

Sol Linderstein

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
 
A

Andre Wisniewski

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
;-) ^^^
 
M

Matt Garrish

Purl Gurl said:
settings\\me\\Desktop` ;

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top