dawg00 Posted May 10, 2010 Share Posted May 10, 2010 The following code is working in the command line(have installed xpdf) #pdftotext /var/www/kweb/a.pdf /var/www/kweb/testFile.txt but when i try to run it with this code in php file its not working <?php $file=$_POST['file1']; echo $file; exec ("pdftotext $file '/var/www/kweb/testFile.txt' "); //line not executing exec ("tr -d '\012' < '/var/www/kweb/testFile.txt' > '/var/www/kweb/tf.txt' "); php?> Plz help me, it urgent.. THnaks a lot Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/ Share on other sites More sharing options...
kenrbnsn Posted May 10, 2010 Share Posted May 10, 2010 Why do you have single quotes around the parameters within then exec() statements? You don't have them when executing from the command line. Ken Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055648 Share on other sites More sharing options...
dawg00 Posted May 10, 2010 Author Share Posted May 10, 2010 exec ("pdftotext $file /var/www/kweb/testFile.txt "); even this does not work.. Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055649 Share on other sites More sharing options...
kenrbnsn Posted May 10, 2010 Share Posted May 10, 2010 When you run the script via a web site, the user it's running under is usually "apache" or "nobody" and this user may not have this command in it's path. Put the fully qualified path in the command. Ken Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055650 Share on other sites More sharing options...
dawg00 Posted May 10, 2010 Author Share Posted May 10, 2010 //tried even this :'( //did not work :'( <?php $file="/var/www/kweb/a.pdf";//full path exec ("pdftotext $file /var/www/kweb/testFile.txt "); exec ("tr -d '\012' < '/var/www/kweb/testFile.txt' > '/var/www/kweb/tf.txt' "); php?> Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055651 Share on other sites More sharing options...
kenrbnsn Posted May 10, 2010 Share Posted May 10, 2010 No, the full path to the pdftotext command. Ken Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055653 Share on other sites More sharing options...
dawg00 Posted May 10, 2010 Author Share Posted May 10, 2010 exec ("/usr/bin/pdftotext /var/www/kweb/a.pdf /var/www/kweb/testFile.txt "); still not working! Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055655 Share on other sites More sharing options...
kenrbnsn Posted May 10, 2010 Share Posted May 10, 2010 Change <?php exec ("pdftotext $file '/var/www/kweb/testFile.txt' ") ?> to <?php exec ("pdftotext $file '/var/www/kweb/testFile.txt' ", $output, $ret); ?> and see if any errors are returned in the $output variable. Ken Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055660 Share on other sites More sharing options...
dawg00 Posted May 10, 2010 Author Share Posted May 10, 2010 <?php exec ("pdftotext $file '/var/www/kweb/testFile.txt' ", $output, $ret); echo "output=$output"; echo "ret=$ret"; ?> i got this.. output=Array ret=2 Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055799 Share on other sites More sharing options...
kenrbnsn Posted May 10, 2010 Share Posted May 10, 2010 Since $output is an array, do <?php echo '<pre>' . print_r($output,true) . '</pre>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055804 Share on other sites More sharing options...
dawg00 Posted May 10, 2010 Author Share Posted May 10, 2010 got this as the output... Array ( ) Link to comment https://forums.phpfreaks.com/topic/201216-need-help-with-executing-this-code-in-php-urgent-help-plz/#findComment-1055853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.