proc_open() 함수를 사용하여 프로세스를 실행하려고합니다. 페이지에 지정된대로 - 사용자 환경 변수를 제공하고 인쇄를 시도했습니다. 그것은 내 모든 공급 변수 + 항상 'SHLVL', 'PWD', '_ ='의 3 가지 변수를 보여줍니다. 제공된 환경 변수 만 인쇄하거나 사용하고 싶습니다. 이 3은 항상이 기능과 함께 있습니까? 변수 만 제공하는 방법이 있습니까? 이것은 Linux와 PHP5 모두에 해당됩니다.PHP proc_open 환경 변수
//Here is the code to clarify :
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);
$env = array('MY_VAR' => 'FOO');
$process = proc_open('./run.php', $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
fwrite($pipes[0], escapeshellcmd($args));
fclose($pipes[0]);
$output = "";
while (!feof($pipes[1])) {
$output .= fgets($pipes[1]);
}
print "Output is $output \n";
fclose($pipes[1]);
$return_value = proc_close($process);
}
감사합니다.
쉘을 여는 이유가 무엇인지 모르겠지만 * do * 할 경우 주변에는 아무 것도 없습니다. –
그건 ... 어디서나 쉘을 호출하지 않습니다 ... –
그리고? 그것은 여전히 쉘을 호출하지 않습니다. –