21,886
社区成员
发帖
与我相关
我的任务
分享
$name = "myserver.com";
function get_host_list($name)
{
$connection = ssh2_connect($name,22);
ssh2_auth_password($connection, 'root','changeme');
$sftp = ssh2_sftp($connection);
$stream = ssh2_exec($connection, 'python file.py');
stream_set_blocking($stream, true);
// Return the result and delete the files
$host_list = stream_get_contents($stream);
return $host_list;
}
echo get_host_list($name);