On Tue, Sep 17, 2002 at 08:00:06AM -0400, FlashGuy wrote:
> Hi,

Hi FlashGuy,

> I have a web interface where I'm executing a compiled perl script. Within the perl 
>script I'm trying to execute a DOS command but its not working properly.
> If I put my command in a batch file and execute the batch file from the perl script 
>it works. I know  it's because copy is not a program...it's a function inside the 
>command.com 
> /cmd.exe shell interpreter.  That's why it works when it's a batch file...because 
>the batch is implicitly run under the shell interpreter.
> 
> This is the line in my perl script that is not quite doing what I want it to do. 
>Copy the file. 
> 
> system("command.com copy /C d:\test\input.ps e:\test\output.ps");
> 
> When I run the above line from a DOS command prompt this is the error I get.
> 
> File not found - D:\TEST\INPUT.PS
>            0 file(s) copied
> 
> What wrong?

In Perl, backslashes escape the character that follows them, just like in C. If
you want a literal backslash, you need either "\\" or '\':

system("command.com copy /C d:\\test\\input.ps e:\\test\\output.ps");

or

system('command.com copy /C d:\test\input.ps e:\test\output.ps');

The latter example is probably perferable.

But that still doesn't explain why it lists the file as "D:\TEST\INPUT.PS",
which seems correct (I would expect it to say something like "D:        EST NPUT.PS".)
But I've never messed with DOS, so I can't be sure.

-- 
Michael

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to