Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Problem with DOS paths in perl - cmd.exe vs. command.exe

Reply
Thread Tools

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

 
 
Sol Linderstein
Guest
Posts: n/a
 
      06-16-2004
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
 
Reply With Quote
 
 
 
 
Andre Wisniewski
Guest
Posts: n/a
 
      06-16-2004
On 16 Jun 2004 10:54:44 -0700, Sol Linderstein <(E-Mail Removed)>
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
 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      06-18-2004

"Purl Gurl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      06-18-2004

"Purl Gurl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Ignorant illiterate troll.
>
> Purl Gurl


We know what you are...

Matt


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.36 Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work? PerlFAQ Server Perl Misc 0 04-26-2011 10:00 AM
Running DOS Commands with Unix UNC Paths within ASP Anonymous ASP General 0 04-03-2008 06:04 AM
Paths, gentleman, paths Ohad Lutzky Ruby 2 11-07-2006 02:15 AM
my own perl "dos->unix"/"unix->dos" Robert Wallace Perl Misc 7 01-22-2004 10:59 PM
Convert between Windows style paths and POSIX style paths Noah Python 5 07-11-2003 09:25 PM



Advertisments