in reply to Re: Net::SCP::Expect Error Handling
in thread Net::SCP::Expect Error Handling

Thanks. Can you please explain the code. especially stdin functionality.

In the mean time , i have used the eval function to catch the error

#!/usr/bin/perl use Net::SCP::Expect; my $user = 'user1'; my $pass = 'pass1'; my $host = 'host1'; my $src_path = "/home/sid.txt"; my $dst_path = "/home/datprd/"; my $s = Net::SCP::Expect->new; $s->login($user, $pass); eval{ $s->scp("$host:$src_path",$dst_path);}; print $@;

Replies are listed 'Best First'.
Re^3: Net::SCP::Expect Error Handling
by salva (Canon) on Jan 29, 2016 at 08:51 UTC
    Under the hood the scp methods in Net::OpenSSH call the scp command.

    The option stdout_file indicates a file name where to redirect the output from the command. stderr_to_stdout indicates that stderr should be send to the same place as stdout. That combination is equivalent to the shell >./scp-capture 2>&1.

      I have executed the command. and its working fine. It also display the error message. It creates the scp-capture file but does not write anything to it.

        It creates the scp-capture file but does not write anything to it.

        Yes, the scp command doesn't output anything by default unless some error happens. You can set the verbose option in order to change that.

      Look like there is some syntax error with your command. Can you please check.

        yes, the closing parenthesis for the unless condition was missing.