View Full Version : exec problem
charan
04-12-2010, 01:14 AM
I am trying to run a shell script from a php file. But I keep getting this error. Do I have to do some changes in the php.ini file??
<b>Warning</b>: exec() [<a href='function.exec'>function.exec</a>]: Unable to fork [echo '************************************************* *******' >> loging.txt] in <b>/home2/xyz/public_html/scripts/runshell.php</b> on line <b>7</b><br />
charan
04-13-2010, 07:10 AM
I have opened 2 tickets in the past one week and still no response from the support staff. Can any kind soul help me out resolve this problem. I just want to know if anyone has used exec before in a php script on hostmonster.
shadmego
04-13-2010, 11:25 PM
Perhaps posting your code would be helpful in troubleshooting your script?
I've used exec before, but I use it in cron jobs and not through activating it through a browser. I don't know if there is a difference.
charan
04-14-2010, 02:23 AM
Thanks to the support team, exec and shell_exec() is working fine on my server, however I have problem with executing my script.
This is the php file.
<?php
shell_exec('/home2/xyz/public_html/scripts/mysh.sh');
?>
Here is the shell script, the script runs as I want it to when I execute in a ssh session on a shell.
#!/bin/sh
# Shell script for auto login and creating the Leads report upto current time of execution of script
rm /home2/xyz/public_html/scripts/Datasheet.xls
rm /home/xyz/public_html/scripts/curlcookies.txt
LOGIN="Log%20in"
curl -c /home2/xyz/public_html/scripts/curlcookies.txt -d "name=XYZ&pass=XYZ&form_id=user_login&op=$LOGIN" http://xyz.com/user/login?splash=off
curl -b /home2/xyz/public_html/scripts/curlcookies.txt http://xyz.com/admin/reports/webfm_statistics_export_report?splash=off > /home2/xyz/public_html/scripts/Datasheetdownload.txt
mv /home2/xyz/public_html/scripts/Datasheetdownload.txt /home2/xyz/public_html/scripts/Datasheet.xls
/ramdisk/bin/php5 -q /home2/xyz/public_html/scripts/sendmail.php
shadmego
04-14-2010, 08:03 AM
Are you getting a different error or the same as your original post?
Is line 7 the first curl command?
charan
04-14-2010, 09:25 AM
Yes line 7 is the first curl command followed by one more. The shell is working fine when I execute it from the terminal.
Now I dont get any error on running the php script as in the original. Infact I dont get anything. The php page takes around 3 mins to load and I have noticed that cpu throttling happens everytime I run the php file.
Here is what the script does. The first curl command authenticates in my website saving a cookie. In the second curl command it fetches a file for me using the cookie which I then rename and mail it as an attachment using the sendmail.php . The cronjob set using the cpanel works great in executing the shell script.
marcaaronhester
05-26-2010, 09:56 AM
did you ever get this figured out? a while back, i had a similar issue and ended up following the instructions in this thread: http://www.hostmonsterforum.com/showthread.php?t=5816
but now that doesn't seem to be working... further investigation has lead me to believe that something's messed up. the thread says to use /usr/bin/php5 which is a symlink that points to /usr/local/bin/php.
problem is that /usr/local/bin/php doesn't seem to exist anymore.
i'll probably submit a ticket... but is anyone else having similar issues?
I contacted support, they told me:
This is a bug that we are working to resolve but it is recommended that you use /ramdisk/bin/php5 instead.
luzagodom
06-08-2010, 04:43 AM
Are you getting a different error or the same as your original post?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.