0

CentOSサーバーでPHPからいくつかのコマンドを実行するためにssh2_execを使用しており、何度も使用していますが、今日、&&を使用して一度に4つまたは5つのコマンドを実行しようとすると、機能しませんでした。以下のコードは次のとおりです。

if (!($stream = ssh2_exec($con, 'cp -rf /home/shared/Tekkit_Server_3.1.2.zip /home/servers2/'.$mUsername.' && unzip /home/servers2/'.$mUsername.'/Tekkit_Server_3.1.2.zip && rm -rf /home/servers2/'.$mUsername.'/mods/mod_NetherOres.jar && mv -f /home/servers2/'.$mUsername.'/Tekkit.jar /home/servers2/'.$mUsername.'/craftbukkit.jar'))) {
    echo "fail: unable to execute command\n";
}

それはZIPを正しいディレクトリにコピーしますが、そこから何もしません、何かアイデアはありますか?

ありがとう!

編集

私はちょうどやってみました:

 if (!($stream = ssh2_exec($con, 'unzip /home/servers2/'.$mUsername.'/Tekkit_Server_3.1.2.zip'))){
                        echo "fail: unable to execute command\n";
 }

そしてそれは戻った:失敗:コマンドを実行することができない

他のコマンドは正常に機能し、ターミナルでコマンドを実行すると正常に機能します。

4

1 に答える 1

1

-d私はあなたの例をテストしました、そしてあなたがコマンドにオプションを提供しunzipてそしてファイルがアンパックされるべきディレクトリを指定するならばそれはうまくいくように見えます:

if (!($stream = ssh2_exec($con, 'unzip /home/servers2/'.$mUsername.'/Tekkit_Server_3.1.2.zip -d /home/servers2/'.$mUsername))){
    echo "fail: unable to execute command\n";
}
于 2012-11-14T23:46:47.257 に答える