سؤال

How do I verify a copied file on a remote server using Perl SCP or is it possible? Below is the Perl command that I am using. I cannot use SSH so my options are somewhat limited.

$scpe->scp("/u02/oraclebackup/$tar_file","HOST:/u04/orabkup/oraclebackup/oemp/");
هل كانت مفيدة؟

المحلول

Ok I've found a solution to my problem and while it doesn't directly verify the copy it will stop the script if there is an error beside the one that is expected. Here is my code:

$scpe->error_handler( \&scp_errors );
$scpe->scp( "/u02/oraclebackup/$tar_file",
    "HOST:/u04/orabkup/oraclebackup/oemp/" );

#Error trapping with exception for known harmless error
sub scp_errors {
    my $line = shift;

    if ( $line =~ /scp timed out while trying to connect to/ ) { 
        return (0);
    } else {
        return (1);
    }   
}

This seems to have solved both of my problems. Thanks @chrsblck

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top