-1

When ever I am trying to execute php script from web server, it fails:

enter image description here

cat test.sh
echo "Hello World"
[root@yumserver ~]#

I am trying to build a button on webpage through which I can push the script to the background..

nohup test.sh &

Please find below the permission/ownership details:

-rwxrwxrwx 1 apache apache 62 Mar 28 04:14 run.php 
-rwxrwxrwx 1 root root 62 Mar 27 06:33 sync.php 

Even I tried CGI-bin but specific script is not getting executed..

#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"
echo "<h1>General system information for host $(hostname -s)</h1>"
echo ""
echo "<h1>Memory Info</h1>"
echo "<pre> $(free -m) </pre>"
echo "<h1>Disk Info:</h1>"
echo "<pre> $(df -h) </pre>"
echo "<h1>Logged in user</h1>"
echo "<pre> $(w) </pre>"
echo "<h1>test</h1>"
echo "<pre> $(sh /var/www/cgi-bin/yumsync.sh) </pre>"  <<<<<
echo "<pre> $(nohup uln-yum-mirror &) </pre>"  <<<<<
echo "<center>Information generated on $(date)</center>"
echo "</body></html>"

yumsync or uln-yum-mirror is the script which I am trying to push it to the background but it's not getting initiated. Any suggestion what could be the cause?

  • what is expected result, how do you know it fails? – Tagwint Mar 28 '16 at 8:41
  • I should say "fail" is a wrong word but test.sh should give me an output like "Hello World" which confirms i'll be able to execute the script but right now its just showing the content of the script rather than result – biz Mar 28 '16 at 8:44
  • is your werbserver able to execute the script (check ownership, groups, etc) ? is your php configuration allowed to execute scripts which are in the root's directory ? – dervishe Mar 28 '16 at 8:45
  • Please find below the permission/ownership details: -rwxrwxrwx 1 apache apache 62 Mar 28 04:14 run.php -rwxrwxrwx 1 root root 62 Mar 27 06:33 sync.php – biz Mar 28 '16 at 8:48
  • Please add any further information into your question (by clicking on the edit link) instead of posting it as a comment. – Jenny D Mar 28 '16 at 8:49
1

Server error logs will almost certainly give you the reason. Assuming it is apache web server, depending on your distro it can be either

/var/log/httpd/error_log

or

/var/log/apache2/error.log

you can conviniently check them with tail or less

  • Thanks Tagwint.. That helped alot. [Mon Mar 28 06:36:25.157815 2016] [cgi:error] [pid 1074] [client 10.47.94.154:60764] AH01215: /usr/bin/uln-yum-mirror: You must be root to run this script, – biz Mar 28 '16 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.