Running cgi scrips

This is a discussion on Running cgi scrips within the Linux Web Servers forums, part of the Web Server and Related Forums category; Help I am trying to run some cgi scripts on my server and have no luck in doing it. In ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-31-2004
John Rusinko
 
Posts: n/a
Default Running cgi scrips

Help

I am trying to run some cgi scripts on my server and have no luck in
doing it. In my error logs I get "Premature end of script headers:" Any
Idea as to what is going wrong? I have these lines in my httpd.conf file:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
Addhandler cgi-script .cgi

The script files are executable

Is their something I have missed?

John

  #2 (permalink)  
Old 09-01-2004
John Rusinko
 
Posts: n/a
Default Re: Running cgi scrips

John Rusinko wrote:

> Help
>
> I am trying to run some cgi scripts on my server and have no luck in
> doing it. In my error logs I get "Premature end of script headers:" Any
> Idea as to what is going wrong? I have these lines in my httpd.conf file:
> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
> Addhandler cgi-script .cgi
>
> The script files are executable
>
> Is their something I have missed?
>
> John
>

OK, I have done some more digging, I have a small cgi script to just
test things out:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello";

That's it, nothing else. when I try to run this script from the command
line using the command /var/www/cgi-bin/test.pl I get ": bad
interpreter: No such file or directory/perl" If I check to see where
perl is on my system, it is in the directory /usr/bin/. I have also
added .pl to the Addhandler cgi-script in the config file.

Any Ideas??
John

  #3 (permalink)  
Old 09-01-2004
Chris Morris
 
Posts: n/a
Default Re: Running cgi scrips

John Rusinko <ponyxprs@rcn.com> writes:
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "Hello";
>
> That's it, nothing else. when I try to run this script from the
> command line using the command /var/www/cgi-bin/test.pl I get ": bad
> interpreter: No such file or directory/perl" If I check to see where
> perl is on my system, it is in the directory /usr/bin/. I have also
> added .pl to the Addhandler cgi-script in the config file.


Did you write this script on a windows system and copy it over?
If so you may be trying to call /usr/bin/perl\r

--
Chris
  #4 (permalink)  
Old 09-01-2004
John Rusinko
 
Posts: n/a
Default Re: Running cgi scrips

Chris Morris wrote:

> John Rusinko <ponyxprs@rcn.com> writes:
>
>>#!/usr/bin/perl
>>print "Content-type: text/html\n\n";
>>print "Hello";
>>
>>That's it, nothing else. when I try to run this script from the
>>command line using the command /var/www/cgi-bin/test.pl I get ": bad
>>interpreter: No such file or directory/perl" If I check to see where
>>perl is on my system, it is in the directory /usr/bin/. I have also
>>added .pl to the Addhandler cgi-script in the config file.

>
>
> Did you write this script on a windows system and copy it over?
> If so you may be trying to call /usr/bin/perl\r
>

nope, used VI right from the console, what does the \r do?

  #5 (permalink)  
Old 09-01-2004
Chris Morris
 
Posts: n/a
Default Re: Running cgi scrips

John Rusinko <ponyxprs@rcn.com> writes:
> Chris Morris wrote:
> > John Rusinko <ponyxprs@rcn.com> writes:
> >
> >>#!/usr/bin/perl
> >>print "Content-type: text/html\n\n";
> >>print "Hello";
> >>
> >>That's it, nothing else. when I try to run this script from the
> >>command line using the command /var/www/cgi-bin/test.pl I get ": bad
> >>interpreter: No such file or directory/perl" If I check to see where
> >>perl is on my system, it is in the directory /usr/bin/. I have also
> >>added .pl to the Addhandler cgi-script in the config file.

> > Did you write this script on a windows system and copy it over?
> > If so you may be trying to call /usr/bin/perl\r
> >

> nope, used VI right from the console, what does the \r do?


Windows line ending is \r\n

So on a unix system expecting the line ending \n the path to the
interpreter assumes the \r as well.

What happens if you type 'perl /var/www/cgi-bin/test.pl' on the
command line?

--
Chris
  #6 (permalink)  
Old 09-01-2004
John Rusinko
 
Posts: n/a
Default Re: Running cgi scrips

Chris Morris wrote:

> John Rusinko <ponyxprs@rcn.com> writes:
>
>>Chris Morris wrote:
>>
>>>John Rusinko <ponyxprs@rcn.com> writes:
>>>
>>>
>>>>#!/usr/bin/perl
>>>>print "Content-type: text/html\n\n";
>>>>print "Hello";
>>>>
>>>>That's it, nothing else. when I try to run this script from the
>>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad
>>>>interpreter: No such file or directory/perl" If I check to see where
>>>>perl is on my system, it is in the directory /usr/bin/. I have also
>>>>added .pl to the Addhandler cgi-script in the config file.
>>>
>>>Did you write this script on a windows system and copy it over?
>>>If so you may be trying to call /usr/bin/perl\r
>>>

>>
>>nope, used VI right from the console, what does the \r do?

>
>
> Windows line ending is \r\n
>
> So on a unix system expecting the line ending \n the path to the
> interpreter assumes the \r as well.
>
> What happens if you type 'perl /var/www/cgi-bin/test.pl' on the
> command line?
>

I get:
"Content-type: texl/html

Hello"

With out the quotes of course, could it be the the script does not know
how to find the perl interpreter? Do I have to add something to a PATH
variable?

John

  #7 (permalink)  
Old 09-01-2004
Chris Morris
 
Posts: n/a
Default Re: Running cgi scrips

John Rusinko <ponyxprs@rcn.com> writes:
> Chris Morris wrote:
> > John Rusinko <ponyxprs@rcn.com> writes:
> >>Chris Morris wrote:
> >>>John Rusinko <ponyxprs@rcn.com> writes:
> >>>>#!/usr/bin/perl
> >>>>print "Content-type: text/html\n\n";
> >>>>print "Hello";
> >>>>
> >>>>That's it, nothing else. when I try to run this script from the
> >>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad
> >>>>interpreter: No such file or directory/perl" If I check to see where

> >
> > What happens if you type 'perl /var/www/cgi-bin/test.pl' on the
> > command line?
> >

> [it works]
>
> With out the quotes of course, could it be the the script does not
> know how to find the perl interpreter?


The error message looks like it's unable to find it, yes.

> Do I have to add something to a PATH variable?


Shouldn't do, you have an absolute path in the shebang line.

What does 'which perl' say? What are the file permissions of
/var/www/cgi-bin/test.pl and /usr/bin/perl?

--
Chris
  #8 (permalink)  
Old 09-01-2004
John Rusinko
 
Posts: n/a
Default Re: Running cgi scrips

Chris Morris wrote:
> John Rusinko <ponyxprs@rcn.com> writes:
>
>>Chris Morris wrote:
>>
>>>John Rusinko <ponyxprs@rcn.com> writes:
>>>
>>>>Chris Morris wrote:
>>>>
>>>>>John Rusinko <ponyxprs@rcn.com> writes:
>>>>>
>>>>>>#!/usr/bin/perl
>>>>>>print "Content-type: text/html\n\n";
>>>>>>print "Hello";
>>>>>>
>>>>>>That's it, nothing else. when I try to run this script from the
>>>>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad
>>>>>>interpreter: No such file or directory/perl" If I check to see where
>>>
>>>What happens if you type 'perl /var/www/cgi-bin/test.pl' on the
>>>command line?
>>>

>>
>>[it works]
>>
>>With out the quotes of course, could it be the the script does not
>>know how to find the perl interpreter?

>
>
> The error message looks like it's unable to find it, yes.
>
>
>>Do I have to add something to a PATH variable?

>
>
> Shouldn't do, you have an absolute path in the shebang line.
>
> What does 'which perl' say? What are the file permissions of
> /var/www/cgi-bin/test.pl and /usr/bin/perl?
>

which perl says "/usr/bin/perl"

Permissions for both /var/www/cgi-bin/test.pl and /usr/bin/perl are

Owner: root
Group: root
Read: Owner, Group, Others
Write: Owner
Exec: Owner, Group, Others

  #9 (permalink)  
Old 09-08-2004
Rusty Wright
 
Posts: n/a
Default Re: Running cgi scrips

Does your apache run chrooted?

John Rusinko <ponyxprs@rcn.com> writes:

> Chris Morris wrote:
> > John Rusinko <ponyxprs@rcn.com> writes:
> >
> >>Chris Morris wrote:
> >>
> >>>John Rusinko <ponyxprs@rcn.com> writes:
> >>>
> >>>>Chris Morris wrote:
> >>>>
> >>>>>John Rusinko <ponyxprs@rcn.com> writes:
> >>>>>
> >>>>>>#!/usr/bin/perl
> >>>>>>print "Content-type: text/html\n\n";
> >>>>>>print "Hello";
> >>>>>>
> >>>>>>That's it, nothing else. when I try to run this script from the
> >>>>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad
> >>>>>>interpreter: No such file or directory/perl" If I check to see where
> >>>
> >>>What happens if you type 'perl /var/www/cgi-bin/test.pl' on the
> >>>command line?
> >>>
> >>
> >>[it works]
> >>
> >>With out the quotes of course, could it be the the script does not
> >>know how to find the perl interpreter?

> >
> >
> > The error message looks like it's unable to find it, yes.
> >
> >
> >>Do I have to add something to a PATH variable?

> >
> >
> > Shouldn't do, you have an absolute path in the shebang line.
> >
> > What does 'which perl' say? What are the file permissions of
> > /var/www/cgi-bin/test.pl and /usr/bin/perl?
> >

> which perl says "/usr/bin/perl"
>
> Permissions for both /var/www/cgi-bin/test.pl and /usr/bin/perl are
>
> Owner: root
> Group: root
> Read: Owner, Group, Others
> Write: Owner
> Exec: Owner, Group, Others

  #10 (permalink)  
Old 09-12-2004
Jonathan2s6
 
Posts: n/a
Default Re: Running cgi scrips

Redhat, Debian, FreeBSD, Windows
High Speed Servers with 1000GB Traffic.

starting at $85

http://www.globalregister.net
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:10 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0