LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-12-2006, 05:50 AM   #1
nutthick
Member
 
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
Code:
/usr/bin/perl test.pl
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
Code:
[error] (2)No such file or directory: exec of /var/www/cgi-bin/test.pl failed
[error] [client 192.168.0.3] Premature end of script headers: /var/www/cgi-bin/test.pl
[error] [client 192.168.0.3] 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
Code:
#!/usr/bin/perl

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
Code:
    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
    </Directory>
Can anyone see why this isn't working? Thanks
 
Old 04-12-2006, 06:38 AM   #2
Alien_Hominid
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, 06:45 AM   #3
nutthick
Member
 
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, 07:02 AM   #4
nutthick
Member
 
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
 
  


Reply


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 08:28 AM
Perl shell-out to script dunna work. Works on command line. Why? jlangelier Linux - Software 1 08-28-2004 02:00 AM
Backspace Not Working In Command Line sanjith11 Programming 1 04-22-2004 07:42 AM
redhat 9 and apache at the command line - help! paulb Linux - General 2 08-07-2003 10:20 AM
perl command line option question afshin Programming 2 01-22-2003 08:16 PM


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

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