dmccull2000
asked on
PHP passthru and exec problems on new server
I am having an issue. I am upgrading a web server with a new server. The previous server used IIS6, PHP, with ISAPI and works fine. On the new server I have purchased a new server, installed PHP but the newest version of PHP now wants CGI. No problem, set this all up and the site works except for areas I use passthru to modify PDFs. Started testing and it appears passthru or exec are not doing nothing.
Here is a test file I created.
<?php
echo "TEST PDFTK<br>";
$fname = $uploaddir.$storybookID.". txt";
$command = "pdftk D:\book\Images\Originals\S ASAKJ5FT.p df dump_data output d:\book\Images\Originals\S ASAKJ5FT.t xt";
echo "command ".$command."<br>";
passthru($command); //run the command
echo $test;
?>
It should create a text file from the document, but from php it does nothing. From command line on the server it works fine. Some of the items I have tried was changing permission on the site to read write execute on the website thinking it may not have permissions to create the file, but this did not work.
Checked the PHP.ini file and I am not running in safe mode.
Not sure what else to check, but will continue troubleshooting.
Here is a test file I created.
<?php
echo "TEST PDFTK<br>";
$fname = $uploaddir.$storybookID.".
$command = "pdftk D:\book\Images\Originals\S
echo "command ".$command."<br>";
passthru($command); //run the command
echo $test;
?>
It should create a text file from the document, but from php it does nothing. From command line on the server it works fine. Some of the items I have tried was changing permission on the site to read write execute on the website thinking it may not have permissions to create the file, but this did not work.
Checked the PHP.ini file and I am not running in safe mode.
Not sure what else to check, but will continue troubleshooting.
Check in the php.ini file to see if this function is listed under 'disable_functions' or do
<?php
phpinfo();
?>
and scan for 'disable_functions'. It is quite common to have two php.ini files - one for command line use and one for web use.
http://uk.php.net/manual/en/ini.core.php#ini.disable-functions
<?php
phpinfo();
?>
and scan for 'disable_functions'. It is quite common to have two php.ini files - one for command line use and one for web use.
http://uk.php.net/manual/en/ini.core.php#ini.disable-functions
ASKER
I checked this, here is the setting in the ini file disable_functions =
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You were close and got me on the right path. d:\PHP is in my path, but PHP is not seeing it as a path. If I added d:\php\pdftk instead of just pdftk it worked, though in the command line it would allow for pdftk since it could access it as part of the path.
In order to keep from having to reprogram the site, I added pdftk.exe to the c:\windows directory.
In order to keep from having to reprogram the site, I added pdftk.exe to the c:\windows directory.
Great stuff. You should be aware that PHP paths always use '/' rather than '\' EVEN WHEN ON WINDOWS machines. PHP converts the separators. This stops the problems of using '\' inside double quoted strings as the '\' is a PHP escape character. So.
$path = "c:/path/to/folder"; and
$path = "c:\\path\\to\\folder" and
$path = 'c:\path\to\folder';
are all equivalent. The difference in the last is because with single quotes the escaping does not occur whereas in double quotes \\ means \
I hope that helps and I am glad your problem is sorted out.
$path = "c:/path/to/folder"; and
$path = "c:\\path\\to\\folder" and
$path = 'c:\path\to\folder';
are all equivalent. The difference in the last is because with single quotes the escaping does not occur whereas in double quotes \\ means \
I hope that helps and I am glad your problem is sorted out.
ASKER