Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

My first CGI code does not seem to work

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

New User

5+ Year Member

joined:Jan 29, 2009
posts: 2
votes: 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

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

Junior Member

5+ Year Member

joined:Dec 20, 2008
posts:92
votes: 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.

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 27, 2001
posts:1472
votes: 0


> my $animall;

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

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

New User

5+ Year Member

joined:Jan 29, 2009
posts: 2
votes: 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.

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

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10544
votes: 8


welcome to WebmasterWorld [webmasterworld.com], here4hlp!

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

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

Junior Member

5+ Year Member

joined:Dec 20, 2008
posts:92
votes: 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.