IT序号网

php之ssh2_exec wget将不起作用

sharpest 2026年05月17日 编程语言 143 0

我想使用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"); 
} 

请您参考如下方法:

我不知道这是否仍然需要,但是看来问题与wget的输出某种程度上有关。如果使用后台选项运行wget,则一切正常:
wget -b /path/to/file


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!