exec 및 shell_exec에 문제가 있습니다. 여기에있는 모든 게시물을 살펴 보았으므로 문제를 찾을 수 없습니다. 내가 사용하고있는 코드 :exec 및 shell_exec이 PHP에서 작동하지 않습니다.
chdir('/');
$handle = shell_exec("/usr/bin/php /home/donor/public_html/batch/testlaunch.php 2>&1");
echo $handle .":". gettype($handle) . "\n";
$read = fread($handle, 2096);
echo $read;
화면은 다음과 같습니다
...
X-Powered-By: PHP/5.3.21 Content-type: text/html (repeated about 100 times)
X-Powered-By: PHP/5.3.21 Content-type: text/html
PHP Warning: shell_exec() [function.shell-exec]: Unable to execute '/usr/bin/php /home/donor/public_html/batch/testlaunch.php 2>&1' in /home/donor/public_html/batch/test.php on line 4 X-Powered-By: PHP/5.3.21 Content-type: text/html
Warning: shell_exec() [function.shell-exec]: Unable to execute '/usr/bin/php /home/donor/public_html/batch/testlaunch.php 2>&1' in /home/donor/public_html/batch/test.php on line 4
:boolean PHP Warning: fread() expects parameter 1 to be resource, boolean given in /home/donor/public_html/batch/test.php on line 6
Warning: fread() expects parameter 1 to be resource, boolean given in /home/donor/public_html/batch/test.php on line 6
:string PHP Warning: fread() expects parameter 1 to be resource, string given in /home/donor/public_html/batch/test.php on line 6 (repeated another 100ish times)
PHP의 안전 모드가 해제됩니다. .../batch /와/usr/bin/php에있는 폴더의 권한은 모두 755로 설정됩니다. 모든 파일의 사용자는 php (php file user는 root)를 제외하고 모두 동일합니다. php.ini 파일에서 아무 것도 비활성화됩니다. CLI에서 제대로 작동합니다. whoami
및 ls
과 같은 간단한 명령이 정상적으로 작동합니다. 난 내가 뭔가를
EDIT를 놓친 거지 같은 느낌 : 무엇 cpattersonv1 말했다 노력하고 있어요 :
X-Powered-By: PHP/5.3.21 Content-type: text/html sh: fork: retry: Resource temporarily unavailable sh: fork: retry: Resource temporarily unavailable sh: fork: retry: Resource temporarily unavailable sh: fork: retry: Resource temporarily unavailable X-Powered-By: PHP/5.3.21 Content-type: text/html sh: fork: retry: Resource temporarily unavailable sh: fork: retry: Resource temporarily unavailable sh: fork: retry: Resource temporarily unavailable sh: fork: retry: Resource temporarily unavailable sh: fork: Resource temporarily unavailable X-Powered-By: PHP/5.3.21 Content-type: text/html 2540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
편집 2 : 그 다음 한 번 더 명령을하려고하는 것 같습니다 사람이 왜 알고 있나요?
EDIT 3 : 명령을 .sh 파일에 넣고 실행하려고했습니다. CLI에서 작동하지만 다시 PHP에서 작동하지 않습니다.
chdir('/');
$handle = exec(". /home/donor/public_html/batch/test.sh");
동일한 결과가 나옵니다.
당신은 ($ 핸들) – m79lkm
"X-구동 - 기준 : PHP/5.3.21 콘텐츠 형식 : text/html 문자열 (641)"위해서 var_dump 때 당신은 무엇을 어떻게해야합니까 X를 -Powered-By : PHP/5.3.21 내용 유형 : text/html string (573) – briandonor