【发布时间】:2014-09-20 12:36:50
【问题描述】:
我正在使用 PHPSeclib 访问安装了 dokku-alt 的服务器:
http://dokku-alt.github.io/how-it-works.html
通过遵循一个典型示例,我设法将命令发送到我帐户上的自定义 shell:
$ssh=$this->connect();
echo trim($ssh->exec("version");
这相当于
ssh dokku@my.node.org version
并按预期工作。但是,如果我尝试执行一个希望我通过 STDIN 发送数据的命令,就会出现问题。根据 Net_SSH2 文档,我需要 write 将数据转换为 SSH 流,而不是使用 exec()。不幸的是,我的下一个示例不起作用,因为自定义 shell 没有接收任何参数并以帮助页面响应:
$ssh=$this->connect();
$ssh->write("mysql mariadb:console myapp newdb\n");
$ssh->write("show tables\n");
$ssh->read('[prompt]');
结果与
相同ssh dokku@my.node.org
它只是用帮助页面来响应。
如何结合“exec”功能并仍然能够写入数据?这样的事情也不起作用:
$ssh=$this->connect();
$ssh->exec("mysql mariadb:console myapp newdb");
$ssh->write("show tables\n");
$ssh->read('[prompt]');
谢谢。
【问题讨论】:
标签: php shell phpseclib dokku dokku-alt