qteks200 Posted November 8, 2009 Share Posted November 8, 2009 Hi there, I created a bash script file using following code to convert doc documents to pdf using OpenOffice macros. ************************* doc2pdf: #!/bin/sh echo "hi" DIR=$(pwd) /usr/bin/oowriter "macro:///Standard.Word2PDF.DOC2PDF($1,$2)" echo "bye" *************************** when i execute doc2pdf /blah/blah.doc /blah/blah.pdf command from gnome-terminal it works fine. But when i use following php script it just echo "hi" and "bye" but it doesn't execute the middle line. *************************** <?php print_r(shell_exec("doc2pdf args blah blah")); ?> *************************** Please help me to find a solution. Bests, Quote Link to comment Share on other sites More sharing options...
trq Posted November 8, 2009 Share Posted November 8, 2009 Firstly, its not a bash script if your using /bin/sh to execute it, its simply a shell script. Is this doc2pdf script within your $PATH, or is it within the same directory as your php script? Quote Link to comment Share on other sites More sharing options...
qteks200 Posted November 9, 2009 Author Share Posted November 9, 2009 Thx thorpe, No it's not in the same directory as my php script. But i don't think this is point. As i mentioned, only middle line (this line `/usr/bin/oowriter "macro:///Standard.Word2PDF.DOC2PDF($1,$2)"`) is not executing. Also i tried shell_exec ('/usr/bin/oowriter "macro:///Standard.Word2PDF.DOC2PDF($1,$2)"'); but the problem still remains. Quote Link to comment Share on other sites More sharing options...
trq Posted November 9, 2009 Share Posted November 9, 2009 Does the user your server runs under have permissions enough to execute that line? Quote Link to comment Share on other sites More sharing options...
patx Posted December 8, 2009 Share Posted December 8, 2009 Hello, I am new to php and i have a similar issue with shell_exec cmd here is my php scripts: testphp.php: <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>testphp</title> </head> <body> <table style="text-align: left; width: 574px; height: 60px;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td></td> <td> <form method="post"> Entrer le numero du user: <input name="user" type="text"> <input type="submit"> </form> <?php $myFile = "testFile.txt"; ?> <?php $fh = fopen($myFile, 'w') or die("can't open file"); ?> <?php $stringData = $_POST['user']; ?> <?php fwrite($fh, $stringData); ?> <?php fclose($fh); ?> </td> </tr> <tr> <td></td> <td> <a href="connect.php">connecter</a></td> <td></td> </tr> </tbody> </table> <br> </body> </html> connect.php <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>connect</title> </head> <body> <?php shell_exec('./connect3.sh');?> <?php echo "patienter 1 minute";?> </body> </html> connect3.sh #!/bin/sh read USR < /home/rom24x/www/testFile.txt rm -rf /home/rom24x/www/flag/user$USR echo 2 > /home/rom24x/www/flag/user$USR The variable is passed from the phpscript to the sh script and echoing sh $USR variable to connect.php also works... If i launch the connect.sh script (same user as server install ) in a terminal, the script works just fine... When launched from PHP script, variables are passed to sh script, sh script echo just fine in PHP but these lines are not: rm -rf /home/rom24x/www/flag/user$USR echo 2 > /home/rom24x/www/flag/user$USR I have setted register_globals to On... Can someone please help me making this work ?!? Thank you 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.