Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-12-2006, 06:50 AM   #1
Registered: Jun 2004
Distribution: Slack
Posts: 214

Rep: Reputation: 30
Perl working at command line, but not in Apache

I have a test perl script, that works on my Windoze box (Just says hello) that I have in /var/www/cgi-bin on my Slackware 10.2 box. When I'm in that directory, if I type
then I get the html the script generates on screen.
However, if I call the script from a PC through Apache, I get error 500. The Apache error log says
[error] (2)No such file or directory: exec of /var/www/cgi-bin/ failed
[error] [client] Premature end of script headers: /var/www/cgi-bin/
[error] [client] File does not exist: /var/www/htdocs/favicon.ico
The test script from the install runs perfectly, and I think I understand why. The first line of the sample script is #!/bin/sh, so I think that is running a bash script. My script is below

print "Content-type: text/html\n\n";
print "<HTML><HEAD>";
print "<TITLE>CGI Test</TITLE>";
print "</HEAD>";
print "<BODY><H2>I just wrote a web page using Perl!</H2>";
print "</BODY></HTML>";
So I'm thinking it must be a Apache conf problem. But I can't see anything wrong with that either. Here is the appropriate section of it
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

    # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    <Directory "/var/www/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
Can anyone see why this isn't working? Thanks
Old 04-12-2006, 07:38 AM   #2
Senior Member
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Did you check the permissions of your file?
Old 04-12-2006, 07:45 AM   #3
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
I knew someone would mention that :P The file permissions and ownership for both the installed file and my test file are the same, 777. They are owned by root and @smbshares.
Old 04-12-2006, 08:02 AM   #4
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
Found the problem. I rewrote the file in vi and it worked. So I used UltraEdit to compare the ascii and Windows was putting in extra 0x0A 0x0D characters at the end of each line, that were throwing the linux system out.

Hope that help someone else


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PERL script OK at command line, not in browser alvo Programming 4 12-19-2004 09:28 AM
Perl shell-out to script dunna work. Works on command line. Why? jlangelier Linux - Software 1 08-28-2004 03:00 AM
Backspace Not Working In Command Line sanjith11 Programming 1 04-22-2004 08:42 AM
redhat 9 and apache at the command line - help! paulb Linux - General 2 08-07-2003 11:20 AM
perl command line option question afshin Programming 2 01-22-2003 09:16 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration