Using the backticks will only get you data coming on handle 1, STDOUT.
You want the data coming on handle 2, STDERR, as well.  You need to
combine them by appending 2>&1 to your system command.

Better yet, use perl's internal file functions like move, copy, rename,
etc.  You get better control, less system overhead, and you can capture
the error messages on $!.

For example:
 rename("$formdata{name}.html",
"/Library/WebServer/Document/About/$formdata{name}.html")
   or die "Error: $!\n";      #####  <= Here's the fun part!

General rule of thumb - if you can avoid using a system call, do so.

Good Luck!
Matt

-----Original Message-----
From: Peter Scott [mailto:[EMAIL PROTECTED]] 
Sent: Monday, August 06, 2001 5:18 PM
To: Chris Garaffa; [EMAIL PROTECTED]
Subject: Re: Calling UNIX Commands?


At 08:15 PM 8/6/01 -0400, Chris Garaffa wrote:

>My question is regarding UNIX commands. I know you can get the output 
>of a
>command using the ` notation. My script has this line:
>my $command = `mv /$formdata{name}.html
/Library/WebServer/Document/About/
>$formdata{name}.html`;

You're on a Mac, and I don't know what 'shell' Perl uses there, but if
this 
were on Unix, you'd need to add a 2>&1 at the end of the command there
if 
you wanted to capture any error text.

>I get no errors, but the file isn't moved, either. Is there a way to do
>this in perl?

You may find it considerably easier in this case simply to say

         rename "/$formdata{name}.html", 
"/Library/WebServer/Document/About/$formdata{name}.html" or die "rename:
$!\n";

:-)

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


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



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

Reply via email to