[PHP] Attempting to use 'passthru' or 'exec' function

2005-01-23 Thread Andre Dubuc
Hi, 

I'm trying to output a text file from a pdf file using an external function, 
pdftotext, using either PHP's 'passthru' or 'exec' functions.

The following code sort of works (at least I see localhost busy doing 
something for about three seconds, but  the expected output of 'content.txt' 
is empty. I used an idea found on the mailing list: I actually got some 
activity with 'sudo desired_function arg1 arg2'.

File permissions are set wide open (apache:apache 777), safe_mode=off.

What am I doing wrong? (Btw, the pdftotext function works fine on 
commandline).

?php

$currentPdf = 2005-01-v2.pdf;
//print $currentPdf;

if (file_exists($currentPdf)) {
passthru(sudo /usr/bin/pdftotext /var/www/html/2005-o1-v2.pdf.txt 
/var/www/html//current.txt);
}

/* Also tried the following using 'passthru' then 'exec':
$pdf = file_get_contents($currentPdf);
//print brbr$Pdf;

passthru(sudo pdftotext /var/www/html/2005-o1-v2.pdf.txt 
/var/www/html/current.txt);
*/

$current = current.txt;

print brbrCurrent Text: $current;
$string_text = file_get_contents(current.txt);
$new_text = nl2br($string_text);

?

Any help, pointers, admonitions gratefully accepted,
Tia,
Andre

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Attempting to use 'passthru' or 'exec' function

2005-01-23 Thread Mikey

Have you tried using the backtick (``) operator?  I don't know if it makes
any difference, but it might be worth a try...

HTH,

Mikey
-Original Message-
From: Andre Dubuc [mailto:[EMAIL PROTECTED] 
Sent: 23 January 2005 21:08
To: php-general@lists.php.net
Subject: [PHP] Attempting to use 'passthru' or 'exec' function

Hi, 

I'm trying to output a text file from a pdf file using an external function,

pdftotext, using either PHP's 'passthru' or 'exec' functions.

The following code sort of works (at least I see localhost busy doing 
something for about three seconds, but  the expected output of 'content.txt'

is empty. I used an idea found on the mailing list: I actually got some 
activity with 'sudo desired_function arg1 arg2'.

File permissions are set wide open (apache:apache 777), safe_mode=off.

What am I doing wrong? (Btw, the pdftotext function works fine on 
commandline).

?php

$currentPdf = 2005-01-v2.pdf;
//print $currentPdf;

if (file_exists($currentPdf)) {
passthru(sudo /usr/bin/pdftotext /var/www/html/2005-o1-v2.pdf.txt 
/var/www/html//current.txt);
}

/* Also tried the following using 'passthru' then 'exec':
$pdf = file_get_contents($currentPdf);
//print brbr$Pdf;

passthru(sudo pdftotext /var/www/html/2005-o1-v2.pdf.txt 
/var/www/html/current.txt);
*/

$current = current.txt;

print brbrCurrent Text: $current;
$string_text = file_get_contents(current.txt);
$new_text = nl2br($string_text);

?

Any help, pointers, admonitions gratefully accepted,
Tia,
Andre

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Attempting to use 'passthru' or 'exec' function

2005-01-23 Thread Jason Wong
On Monday 24 January 2005 05:08, Andre Dubuc wrote:

 I'm trying to output a text file from a pdf file using an external
 function, pdftotext, using either PHP's 'passthru' or 'exec' functions.

 The following code sort of works (at least I see localhost busy doing
 something for about three seconds, but  the expected output of
 'content.txt' is empty. I used an idea found on the mailing list: I
 actually got some activity with 'sudo desired_function arg1 arg2'.

 File permissions are set wide open (apache:apache 777), safe_mode=off.

 What am I doing wrong? (Btw, the pdftotext function works fine on
 commandline).

1) What does your php error log say?
2) Is there any reason you're using sudo? Do you know how it works and have 
you configured sudo correctly?
3) Commands like passthru() and exec() allow you to check the return value of 
the system command being executed -- use it.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php