note 97997 added to function.ssh2-scp-recv

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.