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 Quote Link to comment 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 Quote Link to comment 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.. Quote Link to comment 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 Quote Link to comment 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?> Quote Link to comment 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 Quote Link to comment 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! Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
dawg00 Posted May 10, 2010 Author Share Posted May 10, 2010 got this as the output... Array ( ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.