title: SCP using perl script to transfer files
body: <p>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:</p>
  
  <pre><code>#!/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-&gt;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-&gt;scp($testfile =&gt; $dest))
                   {       my $scp_conn_ex = Net::SCP::Expect-&gt;new;
                           $scp_conn_ex-&gt;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';
  &amp;scp_backup($name, $tfr_type, $ip, $username, $password);
  </code></pre>
  
  <p>However, the transfer doesn't seem to happen. Moreover, no errors are thrown. Where have I gone wrong?</p>