susan lam wrote:
Hi,
I have a script that copies files from one server to
another via the scp system call. On unix, I usually do
a "sum" manually on files to make sure that the files
got transferred properly.


I would like to automate this process in perl -
transferring files over to another server and
verifying that the checksum matches.


$rc=system("scp filea serverb:/tmp");

If $rc==0, does that mean that filea is successfully
copied over to serverb ie the checksum of both files
matched? If not, how can I achieve that?

Thanks in advance.

susan


$rc will contain the return value of system, which is based on the 'wait' call, not the exit value of the underlying called program. This is explained in,


perldoc -f system

Also note that if $rc is -1 then the program failed to start and did not process at all, $! has the reason. Based on a read of the docs the exit value can be retrieved with,

$? >> 8

See the following for a discussion we just had on this topic:

http://groups-beta.google.com/group/perl.beginners/browse_thread/thread/505f193d47b3398e/513b21bd880baeae?_done=%2Fgroup%2Fperl.beginners%2Fthreads%3Fstart%3D30%26order%3Drecent%26&_doneTitle=Back&&d#513b21bd880baeae

As Kevin stated you might be better off using a module from CPAN, in addition to the one he listed there is also Net::SFTP which is based on Net::SSH::Perl. Both I have had good luck with.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to