Php 如何使用ssh2提取zip文件
我正在尝试使用SSH2提取一个ZIP文件,但我运气不好 我尝试过以下代码:Php 如何使用ssh2提取zip文件,php,libssh2,Php,Libssh2,我正在尝试使用SSH2提取一个ZIP文件,但我运气不好 我尝试过以下代码: $connection = ssh2_connect("localhost", 22); if(ssh2_auth_password($connection, "user", "pass")) { $unzip = "unzip /directory/to/file/file.zip"; ssh2_exec($connection,$unzip); } 但它什么也没用。尽管如此,当我直接在终端/命令提示符中键入命令
$connection = ssh2_connect("localhost", 22);
if(ssh2_auth_password($connection, "user", "pass"))
{
$unzip = "unzip /directory/to/file/file.zip";
ssh2_exec($connection,$unzip);
}
但它什么也没用。尽管如此,当我直接在终端/命令提示符中键入命令时,它工作得非常好
我怎样才能让它工作
谢谢 您应该首先使用 然后您可以使用解压:
ssh2_exec($connection,“unzip/path-to-zip/-d/要解压缩的位置”)//语法错误是
$createFolder
应该是$unzip
?您忘记在ssh2\u exec
函数中传递$unzip。抱歉,我重新创建了代码,但不小心忘记将$createfolder更改为$unzip folder。我已经编辑了我的问题。谢谢