Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have this as a seperate PERL file and calling this from another PERL file using system call because my base PERL scripts run via RATLPERL (rational perl)#!/usr/bin/perl -w use strict; use WWW::Mechanize; use HTTP::Cookies; use File::Copy; #use other interl modules; $file_path=$script_path.$exportpath; #opendir(DH,"$file_path"); #readDIR #Setting Env PROXY details # Create a cookie $cookie_jar = HTTP::Cookies->new(file => "$cookie",autosave => 1); $mechanize_obj = WWW::Mechanize->new(autocheck => 1); $mechanize_obj->proxy(https => undef); $mechanize_obj->proxy(http => undef); $mechanize_obj->credentials($loginid => $password); my $response; eval { $response =$mechanize_obj->get($loginurl); }; if ($@) { #Log Error exit 0; } # Store the login response eval { $login_response = $mechanize_obj->response(); }; if ($@) { #Log Error exit 0; } $cookie_jar->extract_cookies($login_response); # save the cookie $cookie_jar->save(); $mechanize_obj->cookie_jar($cookie_jar); # Process each csv files present in the export folder foreach $file(@files_found) { $export_file = $file_path."/".$file; # automate the web upload $mechanize_obj->get($uploadurl); $mechanize_obj->form_number(1); $mechanize_obj->set_fields(theFile => $export_file); $mechanize_obj->submit(); $data=$mechanize_obj->content(); # Write the response content into the upload file &Logs::WriteMessage($data,3); if($mechanize_obj->success) { # move the processed files $status=move("$export_file","$script_path.$pross_exportcsv"); if($status ne 1){#Log Error } } else{#Log Error } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Random error while uploading using WWW::Mechanize
by Anonymous Monk on Dec 01, 2008 at 13:37 UTC | |
by KarthikK (Sexton) on Dec 02, 2008 at 07:41 UTC | |
by Anonymous Monk on Dec 02, 2008 at 09:00 UTC | |
by KarthikK (Sexton) on Dec 02, 2008 at 12:35 UTC |