|
|
Subject:
Post Methode from a Perl script
Category: Computers > Programming Asked by: paul1969-ga List Price: $15.00 |
Posted:
08 Dec 2005 00:36 PST
Expires: 07 Jan 2006 00:36 PST Question ID: 603055 |
Hi, I am trying to POST variables from a Perl script. I have used: 1) use LWP::UserAgent and get as error : 500 Can't connect to www.abc.it:80 (Bad protocol 'tcp') Script: my $url = "http://www.abc.it/cgi-bin/def.pl"; my($ua,$request,$response,%field); undef %field; $field{a} = "123"; $field{b} = "hello"; $field{c} = "true"; $ua = LWP::UserAgent->new; $request = POST $url,\%field; $response = $ua->request($request); # to check response print "Content-type: text/html\n\n"; print $response->header('WWW-Authenticate'); print $response->status_line; print $response->content_type; 2) use IO::Socket; and get as error : No such file or directory Script: $Server = "abc.it/cgi-bin/def.pl"; $sock = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $Server, PeerPort => '80') or &SocketError; Just by trying to open the socket I will get this error. Can someone help me and post me working scripts to send variable from a Perl script by using of the post methode. Also other solutions are welcome. Machine: Apache/2.0.53 (Unix) mod_ssl/2.0.53 OpenSSL/0.9.7e DAV/2 PHP/5.0.3 Server at www.abc.it Port 80 Thanks and regards, Paul1969 |
|
There is no answer at this time. |
|
Subject:
Re: Post Methode from a Perl script
From: ljbuesch-ga on 10 Dec 2005 00:47 PST |
To post data, here is what i use, let me know if it works for you. use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua=LWP::UserAgent->new(); $req=POST $base_url,@fields; $content=$ua->request($req)->as_string; print $content; |
Subject:
Re: Post Methode from a Perl script
From: paul1969-ga on 10 Dec 2005 09:19 PST |
Hi ljbuesch, thanks for the infos. Now I get a different error: Can't call method "header" without a package or object reference at /cgi-bin/def.pl line 559. Line 559: $response = $ua->request($request)->as_string; Some ideas ? I think the major problem in my script was, that I wrote $ua=LWP::UserAgent->new; instead of $ua=LWP::UserAgent->new(); But there is still something wrong. Can you help ? Thanks, Paul |
Subject:
Re: Post Methode from a Perl script
From: paul1969-ga on 15 Dec 2005 10:04 PST |
Ok, I have resolved everything. On my server in /etc/ there was mission the protocols file ! So the tcp prototcol was not located in the right way. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |