Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > POSTing from a perl script to web server

Reply
Thread Tools

POSTing from a perl script to web server

 
 
mozilla.bugzilla@gmail.com
Guest
Posts: n/a
 
      07-08-2005
hi, there

I am a newer to perl. I am trying to write a perl program to
automaticlly submite the form to the webserver.

here is the original html source code,

<form name="ecomm_frm" method="post" action="process.aspx?c=us&amp"
id="ecomm_frm">
<input type="hidden" name="EVENTTARGET" value="EditView:OptOutButton"
/>
<input type="hidden" name="EVENTARGUMENT" value="" />
<input type="hidden" name="VIEWSTATE" value="dDwxMDcyMzE"/>
<script language='javascript'>
<!--
function doPostBack(eventTarget, eventArgument) {
var theform = document.forms['ecomm_frm'];

if( theform == null )
{
//-- Second form is not the search molecule
theform = document.forms[0];
}
theform.EVENTTARGET.value = eventTarget;
theform.EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
<input name="EditView:first" type="text" id="EditView_first" />
<input name="EditView:last" type="text" id="EditView_last" />
<input name="EditView:mEmail" type="text" maxlength="50"
id="EditView_mEmail" />
<a
href="javascript:doPostBack('subscriber:SubmitButt on','')">Submit</a>
</form>


Following is my perl code,


////////////////////////////////////////////////
#!/usr/bin/perl

use strict;
use warnings;
use LWP 5.64;
my $browser = LWP::UserAgent->new;

my $url ='http://mywebsite.......';
my $response = $browser->post( $url,
[ EditView:first => 'mozilla',
EditView:last => 'bugzilla',
EditView:mEmail => '',
EVENTTARGET=>'subscriber:SubmitButton',
EVENTARGUMENT=>'',
VIEWSTATE=>'dDwxMDcyMzE',
]
);

die "$url error: ", $response->status_line
unless $response->is_success;
die "Weird content type at $url -- ", $response->content_type
unless $response->content_type eq 'text/html';
print $response->content;

//////////////////////////////


when I tried to run this, the system always told me there are errors in
these 3 lines: syntax error at line 13 near "Editview". Seems that I
can not include ":" in the entity name. Would you guys help me how to
figure this out? Thanks.

EditView:first => 'mozilla',
EditView:last => 'bugzilla',
EditView:mEmail => '',

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      07-08-2005
wrote in news:1120822018.028426.212100
@z14g2000cwz.googlegroups.com:

> #!/usr/bin/perl
>
> use strict;
> use warnings;


Good. Thank you very much.

> use LWP 5.64;
> my $browser = LWP::UserAgent->new;
>
> my $url ='http://mywebsite.......';
> my $response = $browser->post( $url,
> [ EditView:first => 'mozilla',
> EditView:last => 'bugzilla',
> EditView:mEmail => '',


....

> when I tried to run this, the system always told me there are errors
> in these 3 lines: syntax error at line 13 near "Editview".


'EditView:first' => 'mozilla',
'EditView:last' => 'bugzilla',
'EditView:mEmail' => '',

Sinan

--
A. Sinan Unur <>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      07-08-2005
wrote:
> my $response = $browser->post( $url,
> [ EditView:first => 'mozilla',
> EditView:last => 'bugzilla',
> EditView:mEmail => '',
> EVENTTARGET=>'subscriber:SubmitButton',
> EVENTARGUMENT=>'',
> VIEWSTATE=>'dDwxMDcyMzE',
> ]

<snip>
> when I tried to run this, the system always told me there are errors in
> these 3 lines: syntax error at line 13 near "Editview". Seems that I
> can not include ":" in the entity name. Would you guys help me how to
> figure this out? Thanks.
>
> EditView:first => 'mozilla',
> EditView:last => 'bugzilla',
> EditView:mEmail => '',


The problem here is that the => operator isn't quite magical enough.
The => is defined as a "special" comma. It is special in that it will
automatically quote its left operand *if and only if* that left operand
is a "bareword". A bareword is defined as a sequence of one or more
alpha-numeric characters. If the sequence contains anything else (such
as a colon), it is not a bareword, and the => therefore does not
automatically quote it. You are forced to quote it manually:

'EditView:first' => 'mozilla',
'EditView:last' => 'bugzilla',
'EditView:mEmail' => '',

You can read more about the => operator in
perldoc perlop

Hope this helps,
Paul Lalli

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      07-08-2005
Paul Lalli <> wrote:
> wrote:


>> EditView:last => 'bugzilla',


> The problem here is that the => operator isn't quite magical enough.
> The => is defined as a "special" comma. It is special in that it will
> automatically quote its left operand *if and only if* that left operand
> is a "bareword".



There is an even further restriction (from perldata.pod):

It is often more readable to use the C<< => >> operator between key/value
pairs. The C<< => >> operator is mostly just a more visually distinctive
synonym for a comma, but it also arranges for its left-hand operand to be
interpreted as a string--if it's a bareword that would be a legal identifier.


So, => will autoquote its left operand when that operand matches:

/^[a-z_]\w*$/i


> A bareword is defined as a sequence of one or more
> alpha-numeric characters.



If you had said "can be thought of" instead of "defined as", you
would have been OK.

From perldata.pod again:

A word that has no other interpretation in the grammar will
be treated as if it were a quoted string. These are known as
"barewords".


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      07-08-2005
Tad McClellan wrote:
> Paul Lalli <> wrote:
> > A bareword is defined as a sequence of one or more
> > alpha-numeric characters.

>
>
> If you had said "can be thought of" instead of "defined as", you
> would have been OK.
>


Fair enough. I'll try to be less precise in the future.

Paul Lalli

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments