I wrote the following script in Perl (I'm new to Perl) which attempts to send files via SCP to a remote machine. I'm trying to use Expect to pass the password along. The script so far, looks like this:
#!/usr/bin/perl
use Net::FTP;
use Net::SCP;
use Net::SCP::Expect;
sub scp_backup{
        $n = scalar(@_);
        if ($n == 7)
        {        my $scp_conn = Net::SCP->new($ip, $username) or die "\nCan't open $ip";
                 #die
                 my $dest="/my/remote/location/";
                 my $testfile = "/pah/to/my/file/testing.txt";
                 unless ($scp_conn->scp($testfile => $dest))
                 {       my $scp_conn_ex = Net::SCP::Expect->new;
                         $scp_conn_ex->login($username, $password);
                 }
        }
        else
        {
                print "\nNot enough args\n\n";
        }
        print "\nTotal items passed:$n\n";
}
$name = "testuser";
$tfr_type = "scp";
$ip = "XX.XX.XX.XX";
$username = 'testuser_name';
$password = 'testpass';
&scp_backup($name, $tfr_type, $ip, $username, $password);
However, the transfer doesn't seem to happen. Moreover, no errors are thrown. Where have I gone wrong?
 
    