![]() |
Bash/CGI script won't execute - error 500
Hi all,
I want to display the output of a bash script on a html page using CGI, but I can't get it working... I get an "500 internal server error". I changed the default document root to "/home/www". According to the error.log file Apache can't find the .sh file or am I wrong? But why does it say "/www/cgi-bin/sysinfo.sh" instead of "/home/www/cgi-bin/sysinfo.sh"? And there is something wrong with the permissions too, despite the 755 permission on the script and the cgi-bin folder... Any help? Apache2 error.log: Code:
/home/www/cgi-bin/sysinfo.sh: line 2: /home/www/cgi-bin/sysinfo.sh: Permission deniedCode:
<VirtualHost *:80>/home Code:
drwxr-xr-x 3 root root 4096 2012-06-29 18:07 wwwCode:
drwxr-xr-x 2 root root 4096 2012-06-29 12:57 cgi-bin/Code:
-rwxr-xr-x 1 root root 665 2012-06-29 12:57 sysinfo.shCode:
cat > /home/www/cgi-bin/sysinfo.sh << EOF |
Quote:
- Hello world example in perl - perl test example. Then it should work. - set up cgi-bin in apache Or try google for more good luck |
What distro are you using? If you're using something like Fedora or CentOS then they come with SELinux enabled by default and you need to set the security context in order for httpd to execute cgi...
SAM |
I'm using Ubuntu Server 10.04 LTS
|
Hi, I shortened the test script a little and this is what I get:
(but it still doesn't work...) Code:
[Mon Jul 02 16:01:31 2012] [error] (8)Exec format error: exec of '/home/www/cgi-bin/sysinfo.sh' failedCode:
cat > /home/www/cgi-bin/sysinfo.sh << EOF(which is fine, isn't it?) And I don't get any error messages at all Code:
#!/bin/bash(changes are marked in red) Code:
<VirtualHost *:80>Any help? Thanks!! |
Nvm, I got it working:
Just removing "cat > /home/www/cgi-bin/sysinfo.sh << EOF" works fine for me! |
Quote:
Because if you run "cat" command it expects a filename to parse (and you have just redirected the output to "sysinfo.sh"), without it, it doesn't do anything. |
| All times are GMT -5. The time now is 07:58 PM. |