php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46303 issues when trying to receive file created with ssh2_exec from ssh2_scp_recv
Submitted: 2008-10-15 15:11 UTC Modified: 2008-10-15 15:23 UTC
From: eric_intzandt at tvworks dot com Assigned:
Status: Not a bug Package: Network related
PHP Version: 5.2.6 OS: linux red hat enterprise 4
Private report: No CVE-ID: None
 [2008-10-15 15:11 UTC] eric_intzandt at tvworks dot com
Description:
------------
I create an ssh connection to server b.  I then call ssh2_exec to create a file.  In the same connection, I then call ssh2_scp_recv to grab the file.  However, this returns the file with a size of 0.  If I take out the ssh2_exec() call, and just use ssh2_scp_recv with a pre-existing file it works fine. see code



modules:
	 './configure' '--host=x86_64-redhat-linux-gnu' '--build=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-expat-dir=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--without-mime-magic' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter' '--without-sqlite' '--disable-json' '--without-pspell' 

Reproduce code:
---------------
////////////////////////
Assumes we are connecting to host B, from host A.
////////////////////////

$conn = ssh2_connect($host,22);
  if(ssh2_auth_password($conn,SSH_USER,SSH_PASS))
  {
    $command = "/usr/bin/pg_dump -F t -U ".COMMAND_USER." -d tv -f /home/admin/command_db.tar -i";  
    ssh2_exec($conn, $command );//creates file successfully
    ssh2_scp_recv($conn,'/home/admin/command_db.tar',$dir.'command/'.$host.'/command_db.tar');
  }
  else
    echo "Failed to authenticate";

Expected result:
----------------
I would expect a file command_db to be created on host b, then transferred to host a.  

Actual result:
--------------
File gets created on host B, transferred to host A, but the filesize on host A is 0.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-15 15:23 UTC] eric_intzandt at tvworks dot com
needed to sleep() it longer than i thought. sorry to be a pita
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 14:01:29 2019 UTC