Ask a Question related to PERL Beginners, Design and Development.
-
Nilay Puri #1
uploading fiels from one unix server to another server usin perl cgi script.
No takers ?? :(
> Hi all,
>
> I have a task at hand , that of uplaoding file from server to another
> server and also pass 6 paramteres along with the file.
>
> Basically, I have to replicate the functionality provided by CFHTTP tag of
> COLD FUSION.
>
> I used LWP::UserAgent for the purpose.
> My Program is given below.
>
> #!usr/local/bin/perl
> use LWP::Simple;
> use Data::Dumper;
> use LWP::UserAgent;
> use HTTP::Request::Common qw/POST/;
>
> LWP::Debug::level('+') ;
>
> push(@INC, '/opt/customer/apps/sun-83/nes363/suitespot/cgi-bin/lib/LWP/')
> ;
> my $ua= LWP::UserAgent->new;
> my $file="/home/hewebadm/nilay/test1.txt" ;
> my $filename="323272-1980-test1.txt" ;
> open(READFILE, "<$file") ;
> @data=<READFILE> ;
>
> # HAve to post the content at this URL #
> my $url="http://downloaddev.pearsoncmg.com/extmanage/extpost.php" ;
>
> # Have hard coded the parameters #
>
> $request = POST $url,
> Content_Type => 'application/x-www-form-urlencoded',
> Content => [ action => "insert",
> file => "@data",
> filename => "$filename",
> parentisbn => "0131406701",
> linktext => "test1.txt",
> type => "Presentations",
> imprint =>"ph" ,
> secret =>
> "08ER0L%29N04P73N9%3ACW%2ANC%5F%250%20%0A" ,
> ] ;
>
> my $results=$ua->request($request );
>
> print Dumper($results);
> if($results->is_success){
> print $results->as_string() ;
> print $results->status_line();
> }
>
> On executing this program, I am supposed to get back a URL from the site :
> [url]http://downloaddev.pearsoncmg.com/extmanage/extpost.php[/url]
>
> But I am getting ERROR: <BR> instead.
>
> Here is the output of the program:
> !perl cp_try_lwp.pl
> LWP::UserAgent::new: ()
> LWP::UserAgent::request: ()
> LWP::UserAgent::send_request: POST
> [url]http://downloaddev.pearsoncmg.com/extmanage/extpost.php[/url]
> LWP::UserAgent::_need_proxy: Not proxied
> LWP::Protocol::http::request: ()
> LWP::Protocol::collect: read 12 bytes
> LWP::UserAgent::request: Simple response: OK
> $VAR1 = bless( {
> '_protocol' => 'HTTP/1.1',
> '_content' => 'ERROR: <BR>
> ',
> '_rc' => '200',
> '_headers' => bless( {
> 'connection' => 'close',
> 'x-powered-by' => 'PHP/4.2.2',
> 'client-response-num' => 1,
> 'date' => 'Sat, 31 Jan 2004
> 10:57:02 GMT',
> 'client-peer' =>
> '209.202.161.174:80',
> 'client-date' => 'Sat, 31 Jan 2004
> 10:57:04 GMT',
> 'content-type' => 'text/html',
> 'server' => 'Apache/1.3.20 (Unix)
> PHP/4.2.2',
> 'client-transfer-encoding' =>
> 'chunked'
> }, 'HTTP::Headers' ),
> '_msg' => 'OK',
> '_request' => bless( {
> '_content' =>
> 'action=insert&file=abcsssss%0A+sad%0A+asd%0A+asd% 0A+asd%0A+asd%0A+asda%0A
> +sdas%0A+dasd%0A+fsdf%0A+sdf%0A+sdf%0A+sdf%0A+sdfa %0A+dfasd%0A+fas%0A+dfas
> %0A+dfs%0A+df%0A+sdf%0A+f%0A&filename=323272-1980-test1.txt&parentisbn=013
> 1406701&linktext=test1.txt&type=Presentations&impr int=ph&secret=08ER0L%252
> 9N04P73N9%253ACW%252ANC%255F%25250%2520%250A',
> '_uri' => bless( do{\(my $o =
> 'http://downloaddev.pearsoncmg.com/extmanage/extpost.php')}, 'URI::http'
> ),
> '_headers' => bless( {
>
> 'user-agent' => 'libwww-perl/5.76',
>
> 'content-type' => 'application/x-www-form-urlencoded',
>
> 'content-length' => 339
> },
> 'HTTP::Headers' ),
> '_method' => 'POST'
> }, 'HTTP::Request' )
> }, 'HTTP::Response' );
> HTTP/1.1 200 OK
> Connection: close
> Date: Sat, 31 Jan 2004 10:57:02 GMT
> Server: Apache/1.3.20 (Unix) PHP/4.2.2
> Content-Type: text/html
> Client-Date: Sat, 31 Jan 2004 10:57:04 GMT
> Client-Peer: 209.202.161.174:80
> Client-Response-Num: 1
> Client-Transfer-Encoding: chunked
> X-Powered-By: PHP/4.2.2
>
> ERROR: <BR>
>
> 200 OK
> ERROR: <BR>
>
> I want to know, if I am able to talk to the php program , (since if I do
> not pass the paramnteres, I am prompted with the error of missing
> paramteres.)
> what is wrong with this piece of code ?
>
> And I have no access to the php program.
>
> And I can't suspect the php program to be wrong as the same php program
> when called thru Cold fusion program is able to upload the file
> successfully.
>
> NOTE : I have tried passing the file name as well file data in the line :
> file => "@data",
>
> Please guide me.
>
> Thanks
>Nilay Puri Guest
-
perl script for uploading photo and getting the return value of submit
i just can't make it .. ive made som perl script creating a form for uploading images but my concern is to retrieve the return value of the... -
Uploading to Server
ok, I have designed a database driven site using coldfusion and MYSQL. It works great, and I now want to upload it to the server space I got through... -
Need help with a simple UNIX sockets server based on IO::Socket::UNIX
Hi. I've tried to create a simple client + server that communicate through a unix socket. As with all socket servers, it has a loop where it... -
Permanent connection between a LINUX server and a UNIX AIX server
Hello, I created, for a customer LAMBDA, a Intranet site with PHP and MySQL technology. This site is on a LINUX server. I wish to connect this... -
uploading fiels from one unix server to another server usin perl cgi script.
Hi all, I have a task at hand , that of uplaoding file from server to another server and also pass 6 paramteres along with the file. ... -
Eternius #2
Re: uploading fiels from one unix server to another server usin perl cgi script.
Nilay Puri wrote:
Hi,> No takers ?? :(
>
>
>>>Hi all,
>>
>>I have a task at hand , that of uplaoding file from server to another
>>server and also pass 6 paramteres along with the file.
>>
>>Basically, I have to replicate the functionality provided by CFHTTP tag of
>>COLD FUSION.
>>
>>I used LWP::UserAgent for the purpose.
>>My Program is given below.
>>
>>#!usr/local/bin/perl
>>use LWP::Simple;
>>use Data::Dumper;
>>use LWP::UserAgent;
>>use HTTP::Request::Common qw/POST/;
>>
>>LWP::Debug::level('+') ;
>>
>>push(@INC, '/opt/customer/apps/sun-83/nes363/suitespot/cgi-bin/lib/LWP/')
>>;
>>my $ua= LWP::UserAgent->new;
>>my $file="/home/hewebadm/nilay/test1.txt" ;
>>my $filename="323272-1980-test1.txt" ;
>>open(READFILE, "<$file") ;
>>@data=<READFILE> ;
>>
>># HAve to post the content at this URL #
>>my $url="http://downloaddev.pearsoncmg.com/extmanage/extpost.php" ;
>>
>># Have hard coded the parameters #
>>
>>$request = POST $url,
>> Content_Type => 'application/x-www-form-urlencoded',
>> Content => [ action => "insert",
>> file => "@data",
>> filename => "$filename",
>> parentisbn => "0131406701",
>> linktext => "test1.txt",
>> type => "Presentations",
>> imprint =>"ph" ,
>> secret =>
>>"08ER0L%29N04P73N9%3ACW%2ANC%5F%250%20%0A" ,
>> ] ;
>>
>>my $results=$ua->request($request );
>>
>>print Dumper($results);
>>if($results->is_success){
>> print $results->as_string() ;
>> print $results->status_line();
>>}
>>
>>On executing this program, I am supposed to get back a URL from the site :
>>[url]http://downloaddev.pearsoncmg.com/extmanage/extpost.php[/url]
>>
>>But I am getting ERROR: <BR> instead.
>>
>>Here is the output of the program:
>>!perl cp_try_lwp.pl
>>LWP::UserAgent::new: ()
>>LWP::UserAgent::request: ()
>>LWP::UserAgent::send_request: POST
>>[url]http://downloaddev.pearsoncmg.com/extmanage/extpost.php[/url]
>>LWP::UserAgent::_need_proxy: Not proxied
>>LWP::Protocol::http::request: ()
>>LWP::Protocol::collect: read 12 bytes
>>LWP::UserAgent::request: Simple response: OK
>>$VAR1 = bless( {
>> '_protocol' => 'HTTP/1.1',
>> '_content' => 'ERROR: <BR>
>>',
>> '_rc' => '200',
>> '_headers' => bless( {
>> 'connection' => 'close',
>> 'x-powered-by' => 'PHP/4.2.2',
>> 'client-response-num' => 1,
>> 'date' => 'Sat, 31 Jan 2004
>>10:57:02 GMT',
>> 'client-peer' =>
>>'209.202.161.174:80',
>> 'client-date' => 'Sat, 31 Jan 2004
>>10:57:04 GMT',
>> 'content-type' => 'text/html',
>> 'server' => 'Apache/1.3.20 (Unix)
>>PHP/4.2.2',
>> 'client-transfer-encoding' =>
>>'chunked'
>> }, 'HTTP::Headers' ),
>> '_msg' => 'OK',
>> '_request' => bless( {
>> '_content' =>
>>'action=insert&file=abcsssss%0A+sad%0A+asd%0A+as d%0A+asd%0A+asd%0A+asda%0A
>>+sdas%0A+dasd%0A+fsdf%0A+sdf%0A+sdf%0A+sdf%0A+sd fa%0A+dfasd%0A+fas%0A+dfas
>>%0A+dfs%0A+df%0A+sdf%0A+f%0A&filename=323272-1980-test1.txt&parentisbn=013
>>1406701&linktext=test1.txt&type=Presentations&im print=ph&secret=08ER0L%252
>>9N04P73N9%253ACW%252ANC%255F%25250%2520%250A',
>> '_uri' => bless( do{\(my $o =
>>'http://downloaddev.pearsoncmg.com/extmanage/extpost.php')}, 'URI::http'
>>),
>> '_headers' => bless( {
>>
>>'user-agent' => 'libwww-perl/5.76',
>>
>>'content-type' => 'application/x-www-form-urlencoded',
>>
>>'content-length' => 339
>> },
>>'HTTP::Headers' ),
>> '_method' => 'POST'
>> }, 'HTTP::Request' )
>> }, 'HTTP::Response' );
>>HTTP/1.1 200 OK
>>Connection: close
>>Date: Sat, 31 Jan 2004 10:57:02 GMT
>>Server: Apache/1.3.20 (Unix) PHP/4.2.2
>>Content-Type: text/html
>>Client-Date: Sat, 31 Jan 2004 10:57:04 GMT
>>Client-Peer: 209.202.161.174:80
>>Client-Response-Num: 1
>>Client-Transfer-Encoding: chunked
>>X-Powered-By: PHP/4.2.2
>>
>>ERROR: <BR>
>>
>>200 OK
>>ERROR: <BR>
>>
>>I want to know, if I am able to talk to the php program , (since if I do
>>not pass the paramnteres, I am prompted with the error of missing
>>paramteres.)
>>what is wrong with this piece of code ?
>>
>>And I have no access to the php program.
>>
>>And I can't suspect the php program to be wrong as the same php program
>>when called thru Cold fusion program is able to upload the file
>>successfully.
>>
>>NOTE : I have tried passing the file name as well file data in the line :
>>file => "@data",
>>
>>Please guide me.
>>
>>Thanks
>>
first of all if I post manually, I get a few script warnings.
maybe thats why i does not work.
Warning: Unable to create '/data/web/download.pearsoncmg.com/filetmp/':
Is a directory in
/data/web/download.pearsoncmg.com/htdocs/extmanage/extpost.php on line 27
Warning: Unable to move '/var/tmp/phpdKaae6' to
'/data/web/download.pearsoncmg.com/filetmp/' in
/data/web/download.pearsoncmg.com/htdocs/extmanage/extpost.php on line 27
Warning: Unable to create
'/data/web/download.pearsoncmg.com/htdocs/files/aw/': Is a directory in
/data/web/download.pearsoncmg.com/htdocs/extmanage/extpost.php on line 80
Warning: unlink() failed (Not owner) in
/data/web/download.pearsoncmg.com/htdocs/extmanage/extpost.php on line 81
[url]http://downloaddev.pearsoncmg.com/aw/12876124896/[/url]
Eternius Guest



Reply With Quote

