Page 1 of 1
SSH2 RECEIVE REMOTE FILES!!!!!
Posted: Tue Jun 19, 2007 8:14 am
by spiker84
HI, all!!!!!!!!!
I'm working with ssh2, and when i try to send file to remote machine all it's good!!!!
But when i tired to receive a remote file from my server the browser print this message:
"Warning: ssh2_scp_recv(): Unable to receive remote file"
why this happen??? if i goal to upload file, i must also download!!!!!!
ps: the ssh account is funcionally and i have full permission on file!!!!!
Code: Select all
$connection = ssh2_connect('XXX.XXX.XXX.XXX', 22);
if (ssh2_auth_password($connection, 'dfoiwcbdios', 'XXXXXXXX')) {
echo "Authentication Successful!\n";
}
else {
die('Authentication Failed...');
}
$stdout_stream= ssh2_scp_recv($connection,'C:\TEST.XML','C:\prova.txt');
//echo $stdout_stream;
//ssh2_scp_send($connection, 'C:\Documents and Settings\Utente\Desktop\coccobiwi.txt','C:\coccobiwi.txt');

Posted: Tue Jun 19, 2007 10:11 am
by Begby
Are you using apache or IIS?!??!!!!!!??!!!!!!!!?!!!!!!!!!
You may want to double check that the your local server has access to the directory you are trying to download the file into, if you are using IIS this would mean making sure the IIS machine account has explicit access to C:\ (which is a bad idea, you should use a different folder for testing)!!!!!!!!!!!!!!!!!!!!!!!!!!
Posted: Tue Jun 19, 2007 11:23 am
by volka
If a problem of yours has been solve feedback would be nice, see
viewtopic.php?t=69086
please try
Code: Select all
<?php
$newline = 'cli'==php_sapi_name() ? "\n" : "<br />\n";
$connection = ssh2_connect('XXX.XXX.XXX.XXX', 22);
if (ssh2_auth_password($connection, 'dfoiwcbdios', 'XXXXXXXX')) {
echo "Authentication Successful!\n";
}
else {
die('Authentication Failed...');
}
foreach( array('ls -la', 'dir', 'dir c:\\') as $cmd ) {
echo $newline, $newline, 'cmd: ', $cmd, $newline;
$stdout = ssh2_exec($connection, $cmd);
if ( false===$stdout ) {
echo "'$cmd' failed", $newline;
}
else {
$stderr = ssh2_fetch_stream($stdout, SSH2_STREAM_STDERR);
stream_set_blocking($stdout, true);
stream_set_blocking($stderr, true);
echo 'stdout: ', stream_get_contents($stdout), $newline;
echo 'stderr: ', stream_get_contents($stderr), $newline;
}
}
?>
thks
Posted: Wed Jun 20, 2007 8:04 am
by spiker84
hi and thanks...
i have ApacheSSL 2.2.4 and PHP 5.2.3
ok:
1_ the instructions
Code: Select all
$newline = 'cli' ==php_sapi_name()
doesn't result value -->> $newline always blank
2_ i executed only command dir c:\\ and dir (Winzoz)!!! and it print their result :
ex for dir c:\\ ---------------->>>>
cmd: dir c:\
stdout: Il volume nell'unit… C Š IBM_PRELOAD Numero di serie del volume: 787E-9C70 Directory di c:\ 14/06/2007 17.07 1.024 .rnd 24/02/2007 01.22
ApacheSSL 26/05/2005 15.16
Documents and Settings 27/05/2005 15.45
DownloadDirector 27/05/2005 16.01
DRIVERS 26/05/2005 15.48 1.125 drivez.log 27/09/2001 11.41
I386 26/05/2005 15.00
IBMTOOLS 26/05/2005 15.47
icons 26/05/2005 16.01 155 LOGFILE.txt 12/06/2007 15.23
php 22/05/2007 15.48
php2 18/06/2007 15.32
Programmi 27/05/2005 15.54 199 setup.log 27/09/2001 11.41
SUPPORT 26/05/2005 15.45 640 SYSLEVEL.IBM 27/09/2001 11.41
VALUEADD 19/06/2007 15.43
WINDOWS 5 File 3.143 byte 13 Directory 9.993.531.392 byte disponibili
stderr:
Re: thks
Posted: Wed Jun 20, 2007 9:06 am
by volka
spiker84 wrote:1_ the instructions
Code: Select all
$newline = 'cli' ==php_sapi_name()
doesn't result value -->> $newline always blank
The whole statement is
Code: Select all
$newline = 'cli'==php_sapi_name() ? "\n" : "<br />\n";
and don't worry, it does extacly what it is supposed to do.
spiker84 wrote:cmd: dir c:\
stdout: Il volume nell'unit… C Š IBM_PRELOAD Numero di serie del volume: 787E-9C70 Directory di c:\ 14/06/2007 17.07 1.024 .rnd 24/02/2007 01.22
ApacheSSL 26/05/2005 15.16
Documents and Settings 27/05/2005 15.45
DownloadDirector 27/05/2005 16.01
DRIVERS 26/05/2005 15.48 1.125 drivez.log 27/09/2001 11.41
I386 26/05/2005 15.00
IBMTOOLS 26/05/2005 15.47
icons 26/05/2005 16.01 155 LOGFILE.txt 12/06/2007 15.23
php 22/05/2007 15.48
php2 18/06/2007 15.32
Programmi 27/05/2005 15.54 199 setup.log 27/09/2001 11.41
SUPPORT 26/05/2005 15.45 640 SYSLEVEL.IBM 27/09/2001 11.41
VALUEADD 19/06/2007 15.43
WINDOWS 5 File 3.143 byte 13 Directory 9.993.531.392 byte disponibili
stderr:
apparently there is no file test.xml in c:\ on the server thus you cannot receive that file.
ok
Posted: Wed Jun 20, 2007 10:06 am
by spiker84
the file was present yesteday today i have change it with 2 text file.......and the send function go!!!!
i have full permission in both machine.......
and i don't understand the history of php_sapi_name(); why is blank????? (the result??)
Posted: Wed Jun 20, 2007 10:18 am
by volka
spiker84 wrote:and i don't understand the history of php_sapi_name(); why is blank????? (the result??)
It's certainly not
blank. If you want to
see the return value try
But that has nothing to do with your problem.
spiker84 wrote:the file was present yesteday today i have change it with 2 text file
Are those two files printed in the directory listing?
re
Posted: Wed Jun 20, 2007 10:24 am
by spiker84
yes it are printed