Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ssh2执行工作组赢得';行不通_Php_Ssh - Fatal编程技术网

Php ssh2执行工作组赢得';行不通

Php ssh2执行工作组赢得';行不通,php,ssh,Php,Ssh,我想用ssh2\u exec下载一个文件。 像xdool这样的东西可以工作,但是wget/pkill不行 这是密码 function __construct($host, $user, $pw, $port) { $this->SSHC = ssh2_connect($host, 22); ssh2_auth_password($this->SSHC, $user, $pw); } function downloadFile() {

我想用ssh2\u exec下载一个文件。 像xdool这样的东西可以工作,但是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");
}

尝试使用程序的绝对路径(
/usr/bin/wget
)。通过插入并运行以下命令,可以找到完整路径:

which wget

还可以查看
STDOUT
STDERR
流的输出,以便进一步调试您的问题。

我不知道是否仍然需要这样做,但问题似乎与wget的输出有关。如果使用后台选项运行wget,一切正常:


wget-b/path/to/file

谢谢,Absolute不起作用,但是wget打印了错误“必须连接到终端”,但是我在Internet上找不到任何东西。为了连接,您使用了什么命令?如果您没有-t参数,请尝试添加它,看看这是否解决了您的问题。