Families Laws wrote:
> 
> The Unix command is: `cp -ip $file1 $file2`. I needed
> to know if the cp operation is successful. I tried
> $result = `cp -ip $file1 $file2`;
> $result does not contain any value after the execution
> even when $file1 does not exist.
> 
> How can I find out if the 'cp' operation is successful
> or not ?


use File::Copy;

if ( -e $file2 ) {
    warn "Cannot copy $file1 to $file2: The destination file already exists.\n";
    }
else {
    copy( $file1, $file2 ) or warn "Cannot copy $file1 to $file2: $!";
    }



John
-- 
use Perl;
program
fulfillment

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

Reply via email to