getting error

H

HP

Hi All

when i am trying to run my cgi script my browser giving me this error.
i am using apache server on FC4.

Plese help me out.

ERROR IS

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, (e-mail address removed) and inform them of
the time the error occurred, and anything you might have done that may
have caused the error.

More information about this error may be available in the server error
log.
 
H

HP

Hi Tim

this is the part of my perl cgi script.i am taking user name , passwd
and one more input through browser.
i wana process that infomation and print the result on browser.
but it givving me error which i decribed above.in the error log its
saying that
" Premature end of script headers:"

help me out please


#!/usr/bin/perl
#use warnings;
use HTTP::Request::Common;
use LWP::UserAgent;
use LWP::protocol::http;
use HTTP::Request;
use warnings;
#use LWP::Debug '+';
use Getopt::Long;
use Pod::Usage;
use XML::Simple;
use Data::Dumper;
use CGI;
my $svUser;
my $svPassword;

my $q = new CGI;

$svUser = $q->param("cnt");

$svPassword = $q->param("passwd");

my $cr =$q->param("cr");

my $svRequest = "Login";
my $url = "https://xx.xx.com/fwua.htm";

my $ua = LWP::UserAgent->new;
my $res = $ua->request(POST $url, [svUser => $svUser, svPassword =>
$svPassword, svRequest => $svRequest]);
if ($res->is_success) {
my $resp = $res->as_string;
if($resp =~ /Invalid password/) {
print "Invalid Username/Password\n";
exit 1;
} else {
print "Login successful\n";


# exit with an error if the command-line parameters were not specified
#die "Usage: $0 <userid> <password> \n\n";
#unless defined $URL && length $URL

# Create user agent for querying data
$ua = LWP::UserAgent->new();



# perform the request and obtain the response from the web server;

$req =
HTTP::Request->new('GET',"http://flex.ca.nortel.com/cr?v=v_p&s=r&m=xml&f=a9g1a8dbf6f8ztk9dce1hci1&c=000a91$cr&t=0&t1=1");
$req->authorization_basic("$svUser","$svPassword");
$res = $ua->request($req);
if ($res->is_success)
{

my $data =XMLin($res->decoded_content);
#print Dumper $data
 
H

HP

HP
Jan 3, 4:24 pm show options
Newsgroups: comp.lang.perl.misc
From: "HP" <[email protected]> - Find messages by this author
Date: 3 Jan 2006 03:24:51 -0800
Local: Tues, Jan 3 2006 4:24 pm
Subject: Re: getting error
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Hi Tim

this is the part of my perl cgi script.i am taking user name , passwd
and one more input through browser.
i wana process that infomation and print the result on browser.
but it givving me error which i decribed above.in the error log its
saying that
" Premature end of script headers:"

help me out please

#!/usr/bin/perl
#use warnings;
use HTTP::Request::Common;
use LWP::UserAgent;
use LWP::protocol::http;
use HTTP::Request;
use warnings;
#use LWP::Debug '+';
use Getopt::Long;
use Pod::Usage;
use XML::Simple;
use Data::Dumper;
use CGI;
my $svUser;
my $svPassword;

my $q = new CGI;

$svUser = $q->param("cnt");

$svPassword = $q->param("passwd");

my $cr =$q->param("cr");

my $svRequest = "Login";
my $url = "https://xx.xx.com/fwua.htm";

my $ua = LWP::UserAgent->new;
my $res = $ua->request(POST $url, [svUser => $svUser, svPassword =>
$svPassword, svRequest => $svRequest]);
if ($res->is_success) {
my $resp = $res->as_string;
if($resp =~ /Invalid password/) {
print "Invalid Username/Password\n";
exit 1;
} else {
print "Login successful\n";

# exit with an error if the command-line parameters were not specified
#die "Usage: $0 <userid> <password> \n\n";
#unless defined $URL && length $URL

# Create user agent for querying data
$ua = LWP::UserAgent->new();

# perform the request and obtain the response from the web server;

$req =
HTTP::Request->new('GET',"http://xx/cr?v=v_p&s=r&m=xml&f=a9g1a8dbf6f8ztk9dce1hc...");
$req->authorization_basic("$svUser","$svPassword");
$res = $ua->request($req);
if ($res->is_success)
{

my $data =XMLin($res->decoded_content);
#print Dumper $data
 
J

John Bokma

HP said:
Hi Tim

this is the part of my perl cgi script.i am taking user name , passwd
and one more input through browser.
i wana process that infomation and print the result on browser.
but it givving me error which i decribed above.in the error log its
saying that
" Premature end of script headers:"

help me out please


#!/usr/bin/perl
#use warnings;

why is that off?

use warnings;
use strict;

use CGI::Carp 'fatalsToBrowser';


.... the rest...

Very important, read this first before you reply:
http://groups.google.com/support/bin/answer.py?answer=14213
 
B

Brian Wakem

HP said:
Hi Tim

this is the part of my perl cgi script.i am taking user name , passwd
and one more input through browser.
i wana process that infomation and print the result on browser.
but it givving me error which i decribed above.


I don't see anything above.



in the error log its
saying that
" Premature end of script headers:"

help me out please


#!/usr/bin/perl
#use warnings;
use HTTP::Request::Common;
use LWP::UserAgent;
use LWP::protocol::http;
use HTTP::Request;
use warnings;
#use LWP::Debug '+';
use Getopt::Long;
use Pod::Usage;
use XML::Simple;
use Data::Dumper;
use CGI;
my $svUser;
my $svPassword;

my $q = new CGI;

$svUser = $q->param("cnt");

$svPassword = $q->param("passwd");

my $cr =$q->param("cr");

my $svRequest = "Login";
my $url = "https://xx.xx.com/fwua.htm";

my $ua = LWP::UserAgent->new;
my $res = $ua->request(POST $url, [svUser => $svUser, svPassword =>
$svPassword, svRequest => $svRequest]);
if ($res->is_success) {
my $resp = $res->as_string;
if($resp =~ /Invalid password/) {
print "Invalid Username/Password\n";
exit 1;
} else {
print "Login successful\n";


# exit with an error if the command-line parameters were not specified
#die "Usage: $0 <userid> <password> \n\n";
#unless defined $URL && length $URL

# Create user agent for querying data
$ua = LWP::UserAgent->new();



# perform the request and obtain the response from the web server;

$req =
HTTP::Request->new('GET',"http://flex.ca.nortel.com/cr?v=v_p&s=r&m=xml&f=a9g1a8dbf6f8ztk9dce1hci1&c=000a91$cr&t=0&t1=1");
$req->authorization_basic("$svUser","$svPassword");
$res = $ua->request($req);
if ($res->is_success)
{

my $data =XMLin($res->decoded_content);
#print Dumper $data


a) The code does not compile.
b) You never print a header.

As you are using the CGI module, you can print a header using "print
$q->header();", but you will need to get it to compile before it will work.
 
J

John Bokma

" Premature end of script headers: " = your script isn't sending headers.
You can't just print to the browser, the browser has to know what's
coming, so:

my $cgi = new CGI; # don't use $q, or $query, it's confusing

print $cgi->header( 'text/plain' );
 
T

Tad McClellan

HP said:
my $url = "https://xx.xx.com/fwua.htm"; ^^^
^^^
my $ua = LWP::UserAgent->new;
my $res = $ua->request(POST $url, [svUser => $svUser, svPassword =>
$svPassword, svRequest => $svRequest]);


You should POST data to a CGI program, not to a web page.

ie. You are (probably) using the wrong URL, but that is
not the cause of your current problem.

$req->authorization_basic("$svUser","$svPassword");

perldoc -q vars

What's wrong with always quoting "$vars"?
 
J

Jürgen Exner

HP said:
Hi All

when i am trying to run my cgi script my browser giving me this error.
i am using apache server on FC4.

Plese help me out.

ERROR IS

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Your Question is Asked Frequently.
Please see "perldoc -q 500" for an answer.

jue
 
H

HP

Hi
even after that i am getting the same error.

now my code is.

use strict;
use CGI;
use warnings;
my cgi = new CGI;
print $cgi->header("text/html"),
$cgi->start_html("welcome"),
$q->end_html;

now even this simple program is giving me same error in the errorlog of
apache

" Premature end of script headers:"

please help me out
 
H

HP

HI Now i am not getting the error
but th eoutput is not comming in the browser
my script is now


#!/usr/bin/perl
use strict;
use CGI;
use warnings;
my $cgi = new CGI;
use CGI::Carp 'fatalsToBrowser';

print $cgi->header('text/html');
$cgi->start_html("welcome"),
$cgi->p("hi"),
$cgi->end_html;

my browser is just blank. no output is there
 
P

Paul Lalli

HP said:
#!/usr/bin/perl
use strict;
use CGI;
use warnings;
my $cgi = new CGI;
use CGI::Carp 'fatalsToBrowser';

print $cgi->header('text/html');
$cgi->start_html("welcome"),
$cgi->p("hi"),
$cgi->end_html;

my browser is just blank. no output is there

Why would there be? You didn't print any output. The CGI.pm methods
do not print anything, they simply return strings. You need to
actually print their return values.

print $cgi->start_html('Welcome');
print $cgi->p('hi');
print $cgi->end_html();

Paul Lalli
 
J

John Bokma

HP said:
HI Now i am not getting the error
but th eoutput is not comming in the browser
my script is now


#!/usr/bin/perl
use strict;
use CGI;
use warnings;
my $cgi = new CGI;
use CGI::Carp 'fatalsToBrowser';

My order would be:

#!/usr/bin/perl

use strict;
use warnings;

use CGI::Carp 'fatalsToBrowser';
use CGI;

my $cgi = new CGI;
print $cgi->header('text/html');
$cgi->start_html("welcome"),
$cgi->p("hi"),
$cgi->end_html;

my browser is just blank. no output is there

replace the ; after the $cgi->header('text/html') with a ,
also, to make it visually easier, put 4 spaces in front of the next
lines:

print $cgi->header('text/html'),
$cgi->start_html("welcome"),
$cgi->p("hi"),
$cgi->end_html;

or even:

print

$cgi->header('text/html'),
$cgi->start_html("welcome"),
$cgi->p("hi"),
$cgi->end_html;

(or type 2 spaces extra, YMMV)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top