LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-23-2003, 10:12 PM   #1
Joshsawyer77
LQ Newbie
 
Registered: Dec 2002
Location: Milwaukee
Distribution: Mandrake
Posts: 22

Rep: Reputation: 15
Problems with apache and cgi


I have just set up my apache web server so that I can use the cgi-bin. I made a little hello world script and every thing sorks fine. I then Downloaded a script and tried to run it from my web browser. I get this error:

[Thu Jan 23 21:12:09 2003] [error] [client 10.10.1.10] Premature end of script headers: /var/www/cgi-bin/stats.cgi

I then downloaded another scrip and got the same error. could there be something wrong with my apache configuration that prevents me from running certain scripts? Below is an example of one of the scripts that I downloaded.

$sURLFilter = '';
$sIPFilter = '';
$sHostFilter = '';
$sCounterFilter = '';
$bAutoCreate = 0;


#---------------------------------------------------------------------------

{
local( $__COUNTER_DAT ) = 'livecntr.dat';

print "Content-type: text/plain\nPragma: no-cache\nCache-control: no-cache\nExpires: Mon, 28 Apr 1997 00:01:00 -0500\n\n";

if( $ARGV[0] )
{
local( $nCount ) = 0;
local( $Temp );

if( '' ne $ARGV[4] )
{
$ENV{'HTTP_REFERER'} = $ARGV[4];
}

if( $ARGV[1] && ( '0' ne $ARGV[1] ) )
{
$__COUNTER_DAT = $ARGV[1] . '.lcd';
}

if( -w "$__COUNTER_DAT" )
{
local( $bInc ) = 0;

if( open( F, "+<$__COUNTER_DAT" ) )
{
flock( F, 2 );
seek( F, 0, 0 );

( $Temp, $nCount ) = split( /\s/, <F> );

if( 'i' eq $ARGV[0] )
{
local( $bFiltersOk ) = 1;

if( $sURLFilter && ( lc( $ENV{'HTTP_REFERER'} ) !~ $sURLFilter ) )
{
$bFiltersOk = 0;
}
if( $bFiltersOk &&
$sIPFilter && ( $ENV{'REMOTE_ADDR'} =~ $sIPFilter ) )
{
$bFiltersOk = 0;
}
if( $bFiltersOk &&
$sHostFilter && ( $ENV{'REMOTE_HOST'} =~ $sHostFilter ) )
{
$bFiltersOk = 0;
}
if( $bFiltersOk &&
$sCounterFilter && ( $__COUNTER_DAT =~ $sCounterFilter ) )
{
$bFiltersOk = 0;
}

if( $bFiltersOk )
{
seek( F, 0, 0 );

++$nCount;

print F "Total: $nCount\n";

$bInc = 1;
}
}

flock( F, 8 );
close( F );
}

}
elsif( $bAutoCreate )
{
if( ( !( -e "$__COUNTER_DAT" ) ) && open( F, ">$__COUNTER_DAT" ) )
{
print F "Total: 0\n";
close( F );
}
}

print "c0=$nCount\n";
if( 'v' eq $ARGV[0] )
{
print "vr=99AX\n";
}
}
}
 
Old 01-24-2003, 03:36 AM   #2
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
Just a hunch, here. Did you download the scripts in windows? That would result in that error.
If so, you may have to run dos2unix on the script to convert the dos/windows line endings to unix/linux.

--- Cerbere
 
Old 01-24-2003, 08:10 AM   #3
te_conway
Member
 
Registered: Apr 2001
Location: MA
Distribution: redhat 7.2
Posts: 182

Rep: Reputation: 30
#!/usr/bin/perl -w

should be first line assuming that's where perl is installed
 
Old 01-25-2003, 01:39 PM   #4
Joshsawyer77
LQ Newbie
 
Registered: Dec 2002
Location: Milwaukee
Distribution: Mandrake
Posts: 22

Original Poster
Rep: Reputation: 15
Thank all of you, Cerbere You were right. I ran the dos2unix file tool and works like a champ.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache .cgi execution problems KeithKessler Linux - Software 7 12-01-2004 11:19 AM
Apache CGI problems clb Linux - Networking 2 11-24-2004 10:03 AM
Apache 1.4.7 cgi problems Sm0k3 Programming 1 10-19-2003 02:12 PM
Problems CGI apache Joshsawyer77 Linux - Software 5 01-23-2003 08:56 PM
Apache and SSI/CGI PROBLEMS morbo Linux - Networking 2 01-18-2003 04:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration