CajunCenturion
Programmer
I'm trying to execute an external program from within a PHP script, and the PHP scrips hangs up on the exec command.
Details:
Windows 2008 R2, Apache 2.4, and PHP 5.2.17
The executable was building Visual FoxPro 9.0, SP2.
The exe currently resides in the Windows\System32 directory. It's only there for now to try to take permissions out of the equation.
Here is a snippet of the code:
The values of $filename and $pagenum are correct, and the program itself has been verified. It's works as expected when invoked from Start->Run.
I've tried various combinations of single and double quotes, and I've tried both with and without the addslashes function, all to no avail. I've tried exec, system, and shell_exec functions, and I've also included a dir command exec which works fine.
When the PHP script is executed, it hangs up on the $cvtimg = exec($cvtcmd, $result, $error); line, and the browser reports "transferring data from <IP address>" and just waits. I can find no indication of any error on the server.
Any help is much appreciated.
--------------
Good Luck
To get the most from your Tek-Tips experience, please read
FAQ181-2886
Wise men speak because they have something to say, fools because they have to say something. - Plato
Details:
Windows 2008 R2, Apache 2.4, and PHP 5.2.17
The executable was building Visual FoxPro 9.0, SP2.
The exe currently resides in the Windows\System32 directory. It's only there for now to try to take permissions out of the equation.
Here is a snippet of the code:
Code:
$filename = trim(strtolower($fld[1]->value)) . trim(strtolower($fld[2]->value)) . "." . trim(strtolower($fld[3]->value));
print nl2br ($filename . "\n");
$filename = addslashes($filename);
$pagenum = 1;
$cvtcmd = chr(34) . 'webimage ' . chr(39) . $filename . chr(39) . ' ' . chr(39) . $pagenum . chr(39) . ' > c:\\progout.txt' . chr(34);
print nl2br ($cvtcmd . "\n");
// This is the where it fails
$cvtimg = exec($cvtcmd, $result, $error);
$execln="dir *.* /b/s";
$rc=exec($execln,$a,$r);
print nl2br ( implode($a,"\n")."\n");
print nl2br ( $r."\n");
print nl2br ( '$rc (last line of the output) = '.$rc."\n");
The values of $filename and $pagenum are correct, and the program itself has been verified. It's works as expected when invoked from Start->Run.
I've tried various combinations of single and double quotes, and I've tried both with and without the addslashes function, all to no avail. I've tried exec, system, and shell_exec functions, and I've also included a dir command exec which works fine.
When the PHP script is executed, it hangs up on the $cvtimg = exec($cvtcmd, $result, $error); line, and the browser reports "transferring data from <IP address>" and just waits. I can find no indication of any error on the server.
Any help is much appreciated.
--------------
Good Luck
To get the most from your Tek-Tips experience, please read
FAQ181-2886
Wise men speak because they have something to say, fools because they have to say something. - Plato