I've got to fix this little bug. First, let's talk about a small fact: In CLI on Windows, you can't run a program with a space in its path, unless escaped:
C:\>a b/c.bat
'a' is not recognized as an internal or external command,
operable program or batch file.
C:\>"a b/c.bat"
C:\>
Ben bir süreç (programı) çalıştırmak için PHP proc_open ... proc_close kullanıyorum, örnek:
function _pipeExec($cmd,$input=''){
$proc=proc_open($cmd,array(0=>array('pipe','r'),
1=>array('pipe','w'),2=>array('pipe','w')),$pipes);
fwrite($pipes[0],$input);
fclose($pipes[0]);
$stdout=stream_get_contents($pipes[1]); // max execusion time exceeded ssue
fclose($pipes[1]);
$stderr=stream_get_contents($pipes[2]);
fclose($pipes[2]);
$rtn=proc_close($proc);
return array(
'stdout'=>$stdout,
'stderr'=>$stderr,
'return'=>(int)$rtn
);
}
// example 1
_pipeExec('C:\\a b\\c.bat -switch');
// example 2
_pipeExec('"C:\\a b\\c.bat" -switch');
// example 3 (sounds stupid but I had to try)
_pipeExec('""C:\\a b\\c.bat"" -switch');
Example 1
- SONUÇ: 1
- STDERR: 'C:\a' is not recognized as an internal or external command, operable program or batch file.
- STDOUT:
Example 2
- SONUÇ: 1
- STDERR: 'C:\a' is not recognized as an internal or external command, operable program or batch file.
- STDOUT:
Example 3
- SONUÇ: 1
- STDERR: Dosya adı, dizin adı veya birim etiketi sözdizimi hatalı.
- STDOUT:
So you see, either case (double quotes or not) the code fails. Is it me or am I missing something?