Running cgi scrips
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Web Servers on Unix and Linux > Running cgi scrips




Pages (2): [1] 2 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Running cgi scrips  
John Rusinko


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

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






[ Post a follow-up to this message ]



    Re: Running cgi scrips  
John Rusinko


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

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






[ Post a follow-up to this message ]



    Re: Running cgi scrips  
Chris Morris


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

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





[ Post a follow-up to this message ]



    Re: Running cgi scrips  
John Rusinko


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

Chris Morris wrote:

> John Rusinko <ponyxprs@rcn.com> writes:
> 
>
>
> 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?






[ Post a follow-up to this message ]



    Re: Running cgi scrips  
Chris Morris


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

John Rusinko <ponyxprs@rcn.com> writes:
> Chris Morris wrote: 
> 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





[ Post a follow-up to this message ]



    Re: Running cgi scrips  
John Rusinko


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

Chris Morris wrote:

> John Rusinko <ponyxprs@rcn.com> writes:
> 
>
>
> 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






[ Post a follow-up to this message ]



    Re: Running cgi scrips  
Chris Morris


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

John Rusinko <ponyxprs@rcn.com> writes:
> Chris Morris wrote: 
> [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





[ Post a follow-up to this message ]



    Re: Running cgi scrips  
John Rusinko


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-03-04 01:47 AM

Chris Morris wrote:
> John Rusinko <ponyxprs@rcn.com> writes:
> 
>
>
> The error message looks like it's unable to find it, yes.
>
> 
>
>
> 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






[ Post a follow-up to this message ]



    Re: Running cgi scrips  
Rusty Wright


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-08-04 01:47 AM

Does your apache run chrooted?

John Rusinko <ponyxprs@rcn.com> writes:

> Chris Morris wrote: 
> 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





[ Post a follow-up to this message ]



    Re: Running cgi scrips  
Jonathan2s6


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-12-04 12:46 PM

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

starting at $85

http://www.globalregister.net





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:56 AM.      Post New Thread    Post A Reply      
Pages (2): [1] 2 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register