Click to See Complete Forum and Search --> : exec returns an empty array
cvlug
03-16-2003, 05:10 PM
Hi,
Could anyone please help me?
The exec command from PHP does not return anything on win xp.
This is my code:
$command='M:\gs\gs8.00\lib\ps2ascii M:\gs\gs8.00\lib\a.pdf'
exec($command,$resultArray,$rv);
The application “'M:\gs\gs8.00\lib\ps2ascii” works fine from the command line.
With exec I get an empty $resultArray.
Does anyone know a solution?
(I am getting desperate)
Thanks in advance,
Charles.
cvlug@xs4all.nl
dotwebbie
03-17-2003, 12:58 PM
I didn't look at your code to see if there was a syntax error or anything but try system() instead of exec().
cvlug
03-17-2003, 04:20 PM
I tried that already, it did not help.
When jou search for exec in this forum, you see lot's of other people having the same problem. But nobody has a solution.
I think a possible solution is to spawn the console proces(http://support.microsoft.com/default.aspx?scid=kb;en-us;Q190351).
The sample code given on the url above is a mistery for me.
An other usefull url is:http://mail.python.org/pipermail/python-list/1999-October/014329.html
But i have no idea where to put this code or what to do with it.
Do you have any idea?
thanks for the reaction anyway
Charles
dotwebbie
03-17-2003, 04:46 PM
Give me a chance to check some things.
piersk
03-18-2003, 06:37 AM
Try just putting the command in backticks ` (not '). It returns a string that contains the output of the program, so then you can just echo() the string.
(Please note that I have never tried this, so don't ask me any more about the backtick. This workaround was passed on to me by a friend at uni)
dotwebbie
03-18-2003, 10:36 AM
$command='M:\gs\gs8.00\lib\ps2ascii M:\gs\gs8.00\lib\a.pdf'
should be $command='M:\gs\gs8.00\lib\ps2ascii M:\gs\gs8.00\lib\a.pdf';
It may not fix your problem but it will keep you from getting other problems down the road if/when you try to expand the script.
cvlug
03-19-2003, 05:16 PM
Hi,
I tried all the sugestions, non of them work out.
It not only impossible to get output from the exec function.
The external program I’m using translates pdf to text, and writes the text to a file with the following code from the command line:
“M:\gs\gs8.00\lib\ps2ascii M:\gs\gs8.00\lib\a.pdf M:\gs\gs8.00\lib\a.txt” (called from the lib directory)
This works fine. However with exec it writes an empty text file, when using the following code:
from exec:
”exec('M:\gs\gs8.00\lib\ps2ascii M:\gs\gs8.00\lib\a.pdf M:\gs\gs8.00\lib\a'.txt,$resultArray,$rv);” (called from my web-directory)
What can it be?
Charles.
dotwebbie
03-19-2003, 09:20 PM
Where can I download this program? I want to try a couple of things.
cvlug
03-20-2003, 05:12 AM
Hi Dotwebbie,
You can the latest version of ghostscript at the following adres:
http://www.cs.wisc.edu/~ghost/doc/AFPL/get800.htm
The documentation is not very good.
More documentation can be found on:
http://www.ghostscript.com
Good Luck!
Charles
dotwebbie
03-24-2003, 08:56 PM
Oye. Sorry I haven't replied in so long. College is taking over my life at the moment. :(
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.