現在、必要な前に実行されているシェル コマンドに問題があります。たとえば、連続して実行したい 6 つのコマンドがあり、最初の 5 つのコマンドは正常に動作していますが、前のコマンドによって生成された出力に依存する最後のコマンドに到達すると、実行されません。 . 言い換えれば、5番目のコマンドが完全に完了するまで、最後のコマンドを実行しないようにする方法はありますか? この状況での私のコードのスニペットを簡単に見てみましょう。
/*Renders user image*/
//$command_1 = 'cd ./***/; povray +I'.$newname.' +O'.$newname_t.' +D '.$_POST['AA'].' +H75 +W100';
$command_2 = 'cd ./***/; povray +I'.$newname.' +O'.$newname_i.' +D '.$_POST['AA'].' '.$_POST['resolution'];
/*Command to copy the .pov, .ini, and .inc files from User_Files to the correct animation directory before frame renders can be done*/
$command_cp_pov = 'cp ***'.$newname.' ***'.$location;
$command_cp_ini = 'cp ***'.$newname_j.' ***'.$location;
$command_cp_inc = 'cp *** ***'.$location;
/*Render the frames for the animation*/
$command_3 = 'cd ***'.$location.'; povray +I '.$newname_j.' +A +H384 +W512'.'> /dev/null 2>/dev/null &';
/*Testing purposes*/
//echo $command_3."\n";
/*Throw together the animation using the .png files in the directory*/
$command_4 = 'cd ***'.$location.'; convert -delay 0 -loop 0 *.png animation.gif'.'> /dev/null 2>/dev/null &';
/*Testing purposes*/
//echo $command_4;
$shellOutput = shell_exec($command_2);
$shellOutput = shell_exec($command_cp_pov);
$shellOutput = shell_exec($command_cp_ini);
$shellOutput = shell_exec($command_cp_inc);
$shellOutput = shell_exec($command_3);
// I want this command to run once the previous one is completely finished
$shellOutput = shell_exec($command_4);
5 番目の shell_exec コマンドは、povray を使用して .ini ファイルを実行し、シーンの 50 フレームを作成します。これにより、ImageMagick を使用してこれらのフレームをすべて gif にまとめることができます。ただし、command_3 が完全に終了する (50 フレームすべてがレンダリングされる) まで、command_4 の実行を遅らせる方法が必要なため、現在は正しく動作していません。
すべてのアスタリスク ('*') が何であるか疑問に思っている人がいるとしたら、それはサーバー内の実際の場所を表示することに抵抗があるということです。これが誰かを混乱させたらごめんなさい。