homepage Welcome to WebmasterWorld Guest from 54.167.185.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
My first CGI code does not seem to work
here4hlp




msg:3837852
 11:43 pm on Jan 29, 2009 (gmt 0)

I am now learning Perl/CGI programming. When I tried the very first script:
=============================
#!/usr/local/bin/perl -wT
use strict;
use CGI ':standard';

my $animall;
$animal = param('animal');

print "Content-type: text/html\n\n";
print "Show me the $animal";
======================================
the result was:

"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

"-T" is on the #! line, it must also be used on the command line at c:\inetpub\wwwroot\cgi-bin\perl2e\basics\animal.cgi line 1."

When I removed the "T" from the shebang, result was:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

I am new in learning this program and am doing this on my home computer using Windows XP -IIS server.

How can I resolve this?

Thanks and regards,

here4hlp

 

krugs




msg:3837876
 12:43 am on Jan 30, 2009 (gmt 0)

If you have activeperl installed in the default directory your shebang line is probably wrong:

#!/usr/local/bin/perl -wT

try this for now:

#!c:/perl/bin/perl -w

if that works, add the T switch and see what happens. If your http server does not read the shebang line you will have to learn how to set it up properly to run perl scripts.

Key_Master




msg:3837885
 1:07 am on Jan 30, 2009 (gmt 0)

> my $animall;

You have to declare $animal as a variable or is it a typo?

here4hlp




msg:3837905
 1:31 am on Jan 30, 2009 (gmt 0)

Thanks to both of you - krugs and Key_Master.

Infact, I tried the #!c:/perl/bin/perl -w before submit my post and it also did not work.

For Key_Master, "my $animall" was a typo error in the post.

phranque




msg:3837918
 2:07 am on Jan 30, 2009 (gmt 0)

welcome to WebmasterWorld [webmasterworld.com], here4hlp!

what happens if you try to run c:/perl/bin/perl -w from the command line?

krugs




msg:3837985
 4:00 am on Jan 30, 2009 (gmt 0)


"-T" is on the #! line, it must also be used on the command line at c:\inetpub\wwwroot\cgi-bin\perl2e\basics\animal.cgi line 1."

It appears the http server you are using does not read the shebang line to find perl but it does to load some switches, like -w. I'm not sure which http sever "inetpub\wwwroot" is associated with. If its the windows personal server I have no experience with it and to me that appears to be the problem, not perl. Read your servers help files and see if explains how to run CGI script and use the -T switch. Since Windows ignores the shebang line you can't load the -T switch like you tried which is what that error message above indicates. I recommend you doanload and install apache (its free). Then google for a tutorial or a how-to that explains what you need to do to get it to run CGI scripts. Its not hard but it might take a little time and a few tries to get it to work if you have never done it before.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved