ssh2_exec(cd dir && zip -r dir.zip dir) 创建一个错误的数据文件,而不是按预期创建一个 .zip 文件。
我已经通过命令行使用 ssh2 运行了脚本并且工作正常。我不知道为什么它开始,据我所知,制作一个 zip 文件然后失去连接或提前结束该过程。
Webpage (php):
$conn = ssh2_connect($ip, 22);
ssh2_auth_password($conn, $user, $pw);
$result = ssh2_exec($conn, 'cd /home/dim/remod-racing/ && zip -r maps.zip
/home/dim/remod-racing/maps/');
# --------------------
var_dump($result); //resource(9) of type (stream)
//creates Filetype='File' Size='0' Filename='{generated}'
Debian7 (cmd):
running 'cd /home/dim/remod-racing/ && zip -r maps.zip /home/dim/remod-racing/maps/'
#when ssh'd to the server works however doing it from a php webpage causes it to create a file but with bad data.
//creates maps.zip compressed (zipped) folder as expected
两种方法结果的视图: