<?xml version="1.0" encoding="windows-1252"?>
<node id="1008498" title="debugging Net::Sftp::Foreign using ssh2" created="2012-12-12 07:58:20" updated="2012-12-12 07:58:20">
<type id="115">
perlquestion</type>
<author id="748836">
sdetweil</author>
<data>
<field name="doctext">
I have an application that runs on multiple platforms (windows, linux, solaris, aix, hpux). and uses SFTP to send files to our host server. 
&lt;br&gt;
I needed a 64bit windows version, but the underlying libs for SFTP are not ported to 64bit windows (math::Pari, etc)..
&lt;br&gt;
so I rewrote the function to use SFTP:Foreign and use SSH2.
all works ok so far.. today I received a trouble report, the ftp send fails, leaving a 0 length file on the server. 
&lt;p&gt;
I am trying to figure out how to debug this.. 
&lt;code&gt;
        use Net::SSH2;

        use Net::SFTP::Foreign;
        my $ssh2 = Net::SSH2-&gt;new();
         $ssh2-&gt;debug($debugFlag eq $true ? 1:0);
         $ssh2-&gt;connect($ftpSecureServer)
           or die "Connect failed!\n";
         $ssh2-&gt;auth_password($ftpUser, $ftpPW) 
           or die "password auth failed\n";
           
        $ftp = Net::SFTP::Foreign-&gt;new(ssh2 =&gt; $ssh2,
                    backend =&gt; 'Net_SSH2');
&lt;/code&gt;
from this
&lt;code&gt;
        $ftp = Net::SFTP::Foreign-&gt;
             new(host =&gt; $ftpSecureServer,
                 backend =&gt; 'Net_SSH2',
                 user =&gt; $ftpUser,
                 password =&gt; $ftpPW);
&lt;/code&gt;

both use this code to actually send
&lt;code&gt;
           $ftp-&gt;put( $zipFileName, $ftpDir."/" . $newname );
           if ( !$@ )
           {
              printl("Transmission complete..\n");
              $rc = $true;
           }
           else
           {
           printl("file $zipFileName upload failed, try later\n");
           }
&lt;/code&gt;

the 32 SFTP version does
&lt;code&gt;
          $ftp-&gt;put( $zipFileName, $newname );
          if ( !$error )
          {
            # etc
&lt;/code&gt;

setting SSH2 debug gets me the gory details, but nothing really useful
&lt;code&gt;
libssh2_channel_open_ex(ss-&gt;session, pv_channel_type, len_channel_type, window_s
ize, packet_size, ((void *)0) , 0 ) -&gt; 0x47dc418
Net::SSH2::Channel::read(size = 4, ext = 0)
- read 4 bytes
- read 4 total
Net::SSH2::Channel::read(size = 5, ext = 0)
- read 5 bytes
- read 5 total
&lt;/code&gt;

anyone have any suggestions?</field>
</data>
</node>
