note 97997 added to function.ssh2-scp-recv

From: Date: Wed, 19 May 2010 22:16:32 +0000
Subject: note 97997 added to function.ssh2-scp-recv
Groups: php.notes 
Request: Send a blank email to php-notes+get-169432@lists.php.net to get a copy of this message
This function can be used to copy all files into a directory on a remote server, using SSH and SCP. $connection = ssh2_connect('host', 22); ssh2_auth_password($connection, 'user', 'password'); $remote_dir="/remote_dir/"; $local_dir="/local_dir/"; $com ="ls $remote_dir"; $stream = ssh2_exec($connection, $com); stream_set_blocking($stream,true); $cmd=fread($stream,4096); $arr=explode("\n",$cmd); $total_files=sizeof($arr); for($i=0;$i<$total_files;$i++){ $file_name=trim($arr[$i]); if($file_name!=''){ $remote_file=$remote_dir.$file_name; $local_file=$local_dir.$file_name; if(ssh2_scp_recv($connection, $remote_file,$local_file)){ echo "File ".$file_name." was copied to $local_dir<br />"; } } } fclose($stream); ---- Server IP: 69.147.83.197 Probable Submitter: 201.247.101.137 ---- Manual Page -- http://www.php.net/manual/en/function.ssh2-scp-recv.php Edit -- https://master.php.net/note/edit/97997 Del: integrated -- https://master.php.net/note/delete/97997/integrated Del: useless -- https://master.php.net/note/delete/97997/useless Del: bad code -- https://master.php.net/note/delete/97997/bad+code Del: spam -- https://master.php.net/note/delete/97997/spam Del: non-english -- https://master.php.net/note/delete/97997/non-english Del: in docs -- https://master.php.net/note/delete/97997/in+docs Del: other reasons-- https://master.php.net/note/delete/97997 Reject -- https://master.php.net/note/reject/97997 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169432) next »