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 "<br><br>$Pdf";

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

$current = "current.txt";

print "<br><br>Current 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

Reply via email to