我想使用ssh2_exec下载文件。 像xdotool这样的东西可以工作,但是wget / pkill不会。
这是代码
function __construct($host, $user, $pw, $port) {
$this->SSHC = ssh2_connect($host, 22);
ssh2_auth_password($this->SSHC, $user, $pw);
}
function downloadFile() {
ssh2_exec($this->SSHC, "wget http://path/to/file");
}
答案 0 :(得分:1)
我不知道是否还需要这个,但看起来这个问题与wget的输出有某种关系。如果你用后台选项运行wget,一切正常:
wget -b /path/to/file
答案 1 :(得分:0)
尝试使用程序的绝对路径(/usr/bin/wget
)。你可以通过PUTTYing找到完整的路径:
which wget
另请查看STDOUT
和STDERR
流的输出,以便进一步调试您的问题。