chameliun has asked for the wisdom of the Perl Monks concerning the following question:

Monks of great perl wisdom I seek guidance. I have a form that posts to a perl script. The script to submit says that it submitted correctly, but the other form says otherwise, specifically it says"--xYzZY-- -- Bad length". Here is the following form
<form enctype=multipart/form-data method=post action=/cgi-access/bulk. +pl> File name: <input type=file size=45 name=filename><p> <input type=submit value=Send File> <input type=reset value=Clear> </form> and the perl script #!/usr/local/bin/perl -w require LWP::Simple; require HTTP::Request; require LWP::UserAgent; require HTML::Form; $user_agent = LWP::UserAgent->new; $filename ='/usr/local/www/http/cgi-bin/test/cards.txt'; $url ='https://mysite:808/access/bulk.html'; $user =""; $pass=""; $request = HTTP::Request->new(GET=> $url); $request->authorization_basic($user,$pass); $response=$user_agent->request($request); print $response->as_string; @form = HTML::Form->parse($response->content,$response->base); $form = shift @form; @inputs = $form->inputs; $input = $form->find_input( "filename" ); if($input){ print "found it!\n"; $input ->file('/usr/local/www/http/cgi-bin/test/cards.txt'); } $test = $form->click(); $test->authorization_basic($user,$pass); $response=$user_agent->request($test); print $response->as_string; if($response->is_success){ print "It's good!\n"; } else { print "It didn't work.\n"; print $results->status_line(); }

Replies are listed 'Best First'.
Re: Automate Form Submission
by esskar (Deacon) on Mar 04, 2004 at 04:15 UTC
    1. use strict :)
    2. it looks good to me; i tried your script but just using http; you may want to upload that stuff to some https server (accessable to the world) so i can run a check!
      Sorry, I can't easily do that. But I have another question, it appears that when I submit from the form that the other script is reading where the submit is coming from, but when I run my script instead of saying where it is coming from it only has a "-" in it. I am not sure what kind of header method I should be changing. Anyone have an idea? Even better how can I grab all information from both the form and the script so that I can compair how the differ? Thanks
        I got it! It turns out that the script on the backend was what was bad. The person who wrote it did not use cgi.pm and did there own parsing of the data. This caused it handle the data I was POSTing in a non standard way...