I have this problem about 4 days and can't find any solution .
I 'm trying to call a executable with proc_open() (i have tried system() , exec() and popen() but i had the same results ) , the problem is too weird because this executable is running perfect in command prompt but in php the executable return " EInOutError: I/O error 6 " , i have run my php script with other executables and it runs correctly , so i create a simple executable with Delphi and the only thing is doing is echoes "from cmd" and then i run it from cmd and was correctly executed so i run it from php i get
so my question is :
why i can't execute any console executable from php compiled with Embarcadero Delphi 2010 ?
what is the difference from a real command prompt and the proc_open() ?
my system is a windows 7 prof x64 i run the latest xampp (apache runs as a service )
i tested in a windows xp 32 bit latest xampp (apache runs as service ) but i get same results
thanks for your time jkarr .
my php code
Code: Select all
class Process
{
public static function open($command)
{
$retval = '';
$error = '';
$descriptorspec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w')
);
$resource = proc_open($command, $descriptorspec, $pipes, null, $_ENV);
if (is_resource($resource))
{
$stdin = $pipes[0];
$stdout = $pipes[1];
$stderr = $pipes[2];
while (! feof($stdout))
{
$retval .= fgets($stdout);
}
//while (! feof($stderr))
//{
$error = fgets($stderr);
//}
fclose($stdin);
fclose($stdout);
fclose($stderr);
$exit_code = proc_close($resource);
}
if (! empty($error))
throw new Exception($error);
else
return $retval;
}
}
try
{
$output = Process::open('cd ../htdocs/ccc/ & testDelphi.exe');
echo $output;
// do something with the output
}
catch (Exception $e)
{
echo $e->getMessage() . "\n";
// there was a problem executing the command
}