Solved

Post file to remote server using PERL??

Posted on 2003-11-07
4
487 Views
Last Modified: 2013-12-25
1. A form resides on a remote server.
2. I want a PERL script to simulate filling in the form, including a file field, and then submittnig it.
3. Display the resulting page.

So basically I need to post several fields(one of which is a file field) to a server and then display the results.

JJ
0
Comment
Question by:jimmyjoe
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 9711033
what's the URL of the form?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 9711776
LWP::UserAgent is your tool, eg:

use LWP::UserAgent;
  $ua = LWP::UserAgent->new;  my $req = HTTP::Request->new(POST => 'http://www.perl.com/cgi-bin/BugGlimpse');
  $req->content_type('application/x-www-form-urlencoded');
  $req->content('match=www&errors=0');  my $res = $ua->request($req);
  print $res->as_string;
0
 

Author Comment

by:jimmyjoe
ID: 9712321
0
 
LVL 2

Accepted Solution

by:
Itatsumaki earned 200 total points
ID: 9724060
I think WWW::Mechanize is better for this than LWP::UserAgent
I use this exact approach to automate testing of CGI-based sites with Test::More.
Here is some code to do what you are asking.

###
use WWW::Mechanize;

my $url = 'http://xxx.xxx.xxx.xxx/cgi-bin/addvalues_entry.cgi?user_id=qwerty';

my $mech = WWW::Mechanize->new();

$mech->get($url);

$mech->form_number(1);
$mech->field('datafield', '10-Nov-2003');
$mech->field('filename', 'abcdabcd.zyx');
$mech->click('Submit');

print $mech->title(), "\n";
print $mech->content();
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to get a list of users From AD 13 128
How to count json data 2 67
Modifying Powershell script to get the size of the directory ? 2 49
What is assert.deepEqual? 4 39
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now