php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26513 ps2pdf command works in CLI, not CGI
Submitted: 2003-12-03 14:48 UTC Modified: 2003-12-05 03:04 UTC
From: fgasper at freeshell dot org Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 4.3.4 OS: FreeBSD 4.9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fgasper at freeshell dot org
New email:
PHP Version: OS:

 

 [2003-12-03 14:48 UTC] fgasper at freeshell dot org
Description:
------------
I am producing PostScript reports from a database application with PHP. Since most of my users won't have GhostScript or anything like that installed, I want to display the reports as PDFs. My problem is that ps2pdf doesn't appear to be executing.

I tried running my script in CLI mode, though, and it worked just fine.

The code example below illustrates the problem. I have its output here:

CGI/Apache: --------------------
1070480700.11
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps

1070480700.12
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps


CLI: -------------------
1070480804.37
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps

1070480818.42
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps

Reproduce code:
---------------
<?php

header('Content-type: text/plain');

print array_sum(explode(" ",microtime()))."\n";
system('ls -la /tmp/fshn*');
print "\n";

exec('/usr/local/bin/ps2pdf /tmp/fshn.ps');

print array_sum(explode(" ",microtime()))."\n";
system('ls -la /tmp/fshn*');
print "\n";

?>


Expected result:
----------------
1070480804.37
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps

1070480818.42
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps

Actual result:
--------------
1070480700.11
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps

1070480700.12
-rw-r--r--  1 fgasper  wheel  1440973 Dec  3 13:25 /tmp/fshn.ps

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-03 15:19 UTC] fgasper at freeshell dot org
I tried changing the exec line to:

----------
print system("/usr/local/bin/ps2pdf /tmp/fshn.ps");
----------

Also tried running this on a Gentoo box that I have which runs PHP 4.3.2. These revealed the following:

1) The Gentoo box gives two iterations of
"**** Unable to open the initial device, quitting."
upon execution via CGI. Not sure why this is, but it doesn't seem to be related to this particular problem because...

2) CGI from the FreeBSD box gives no response at all from the system() command.

3) The CLI mode in Gentoo works fine, just as it does in FreeBSD.
 [2003-12-04 02:21 UTC] sniper@php.net
Try running gs binary directly instead of using the wrapper shell scripts. (in my system ps2pdf first calls ps2pdf12 which calls ps2pdfwr which calls the gs binary with appropriate options)

And check the execute permissions on all those scripts..?
Try running the command with this:

exec ($cmd, $output, $retval);

Then you can check what the command returns as retval in $retval.


 [2003-12-05 00:31 UTC] fgasper at freeshell dot org
Apparently that was the issue, yes; running the binary directly with all the switch wizardry works.

Sorry for the bogie...:(
 [2003-12-05 03:04 UTC] derick@php.net
Bogus as you said...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC