怎样在网页中显示ssh2_exec得到的结果?
现在的问题是结果可以正确返回,但网页显示不了
我的代码如下,文件名是demo.php:
$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);如果在shell中运行代码
php demo.php,结果可以正确显示。
但如果我在浏览器中打开此文件
www.path/to/the/file.demo.php
则不显示任何东西。。
为什么shell中可以显示结果但网页中就现实不了呢??
个人猜测是不是因为当网页已经load了,但结果还没返回过来,所以没有东西可以显示?
请大虾帮忙解决,急~ 谢谢
相关推荐
node-ssh2-exec:SSH2登录和执行的节点插件
节点-ssh2-exec SSH2登录和执行的节点插件 如何使其运作? cd节点-ssh2-exec / npm安装 这个怎么运作? # # Run command "node shell.js" inside the app folder & provide the necessary details required # to login into the server. Username & hostname are required fields. # > node shell.js Deployment Engine Node Plugin for SSH2. Usage: /usr/local/bin/node shell.js --options... Options: -u, --username, --user SSH Login Usernam
用paramiko:ssh.exec_command怎样运行import命令
各位大神,搭救搭救老弟~~ 我用ssh.exec_command(comm)运行py文件,问题是我的py文件import了很多东西。 这里我看了网上说exec调用有着类似于import的效果,但是,它从技术上不会导入模块,默认情况下,每次以这种方式调用 exec的时候,它都重新运行文件, 就好像我们把文件粘贴到了调用exec的地方 。因此, exec不需要在文件 修改后进行模块重载 ,它忽略了常规的模块导入逻辑。 https://blog.csdn.net/fhd001/article/details/6753013 也有大佬遇到过类似问题:https://stackoverflow.com/
ssh-exec, 使用 node.js 在ssh上执行脚本.zip
ssh-exec, 使用 node.js 在ssh上执行脚本 ssh在ssh上执行脚本,使用 node.js 和管道,并从可以通过npm提供。npm install ssh-exec它是用普通的Javascript编写的,使用了 ssh2作为所有重。用法var ex
windows平台上采用libssh2开发的SSH
使用libssh2开发的一个SSH,终于写好了,分享给大家。
node-ssh-exec:一个简单的 ssh2 包装器,用于使用 Node.js 通过 ssh 在遥控器上执行 shell 命令
节点-ssh-exec 一个简单的 ssh2 包装器,用于使用 Node.js 通过 ssh 在遥控器上执行 shell 命令。 安装 npm install node-ssh-exec 用法 var exec = require ( 'node-ssh-exec' ) ; var // see https://github.com/mscdex/ssh2 config = { host : 'localhost' , username : 'root' , password : 'root' } , command = 'ls -alh' ; exec ( config , command , function ( error , response ) { if ( error ) {


基础编程
