View previous topic :: View next topic |
Author |
Message |
The Mad Crapper Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/135303727943cbcc9e4a2d1.gif)
Joined: 08 Aug 2005 Posts: 156
|
Posted: Thu Nov 10, 2005 1:48 am Post subject: Running Perl CGIs - not working |
|
|
so i am trying to run some perl scripts that are in the my cgi-bin directory and i am getting a 500 server error. I can run sh scripts but not perl the 500 page tells me to look at the error log. in the error log i have Code: | malformed header from script. Bad header=This is a test. content: perl-test | 'This is a test. content' is the output of the perl script when run...
what am i missing? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
d11wtq Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/1790896682437f3ff79b696.gif)
Joined: 14 Jul 2005 Posts: 192 Location: Manchester, UK
|
Posted: Thu Nov 10, 2005 2:01 am Post subject: |
|
|
Post the perl script please.
Also... make sure you have it chmod to allow apache to execute it. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
The Mad Crapper Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/135303727943cbcc9e4a2d1.gif)
Joined: 08 Aug 2005 Posts: 156
|
Posted: Thu Nov 10, 2005 2:12 am Post subject: |
|
|
i just tried to run the perl script on one of the web servers at my work that i know runs perl CGIs and i got the same thing, so the problem must be with my novice perl skills!
Code: |
#!/usr/bin/perl
$foo = "content";
print "This is a test. $foo\n";
|
and i know the apache user can run it, the permissions are correct. (the first error i got was because of permissions) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
The Mad Crapper Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/135303727943cbcc9e4a2d1.gif)
Joined: 08 Aug 2005 Posts: 156
|
Posted: Thu Nov 10, 2005 2:50 am Post subject: |
|
|
anyone know why it runs on the command prompt, but not if called by apache? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
wjholden l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 01 Mar 2004 Posts: 826 Location: Augusta, GA
|
Posted: Thu Nov 10, 2005 3:15 am Post subject: |
|
|
You have to tell the browser what it's reading before sending content, which means you need to send this or similar line before all other output: Code: | Content-type: text/html\n\n | So your test script should really look like this: Code: | #!/usr/bin/perl
print "Content-type: text/html\n\n";
$foo = "content";
print "This is a test. $foo\n"; | If that doesn't work, you really do have a problem.
Actually, many people don't realise this, you can put any executable in your CGI bin, say a C program or whatever, meaning if you compile a C program and drop the binary into your CGI bin and print to stdout and read from stdin (before output, never after) it should work (example, source).
There are other mimetypes you may want to use, such as "Content-type: text/plain\n\n". |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
The Mad Crapper Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/135303727943cbcc9e4a2d1.gif)
Joined: 08 Aug 2005 Posts: 156
|
Posted: Thu Nov 10, 2005 3:25 am Post subject: |
|
|
oh rock on man. thats it! thank you! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|