Solved

Post file to remote server using PERL??

Posted on 2003-11-07
4
506 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
 
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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

691 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