diamondsandperls has asked for the wisdom of the Perl Monks concerning the following question:
Please help the scalar that is getting submitted for $input_data when this is submitted it is all one line. The file it reads in has line breaks. txtIncidentDescription is the description field that is having the issue. I am reading in the file with File::Slurp.
#!perl use strict; use warnings; use WWW::Mechanize; use Term::InKey; use Win32::Clipboard; use File::Slurp; my $ua = LWP::UserAgent->new; #DETERMINING END USER my $oldSSO = qx{whoami}; chomp $oldSSO; my ($sso) = $oldSSO =~ /.*(\w{2}\d{5})/; #PROMPTING FOR PASSWORD print "Enter Password: "; my $pass = &ReadPassword; chomp $pass; #SETTING DATA TO SUBMIT my $input_data = read_file( 'C:/temp/vpn_user.txt' ); #DECLARE URL VARIABLES my $url1 = "https://url1"; my $url2 = "https://url2"; my $url3 = "https://url3"; #TURN OFF SSL CHECKING $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; #MECHANIZE TO GET AND PRINT CONTENT my $mech = WWW::Mechanize->new(timeout => 60, autocheck => 1); #SET COOKIE JAR $mech->cookie_jar(HTTP::Cookies->new); #USER AGENT $mech->agent_alias( 'Windows IE 6' ); $mech->get($url1); $mech->form_name('Login'); $mech->field(USER => "$sso"); $mech->field(PASSWORD => "$pass"); $mech->click(); $mech->get($url2); #SET FORM VALUES $mech->form_name('frmTicketCreate'); $mech->field('ddlProducts' => 1245); $mech->field('txtIncidentDescription' => $input_data); $mech->field('ctrlAssignedGroupLookup_mTxtName' => "assigned team"); $mech->field('__EVENTTARGET', 'ctrlAssignedGroupLookup_mBtnSearch_lnkB +utton'); $mech->submit('ctrlAssignedGroupLookup_mBtnSearch_lnkButton'); my $content_login = $mech->content(); my ($number) = $content_login =~ /ctrlAssignedGroupLookup_mCBLLookupGr +oups\S value\S\S(\d+)/; #print $number, "\n"; $mech->field('ctrlAssignedGroupLookup_mCBLLookupGroups' => $number); #$mech->form_name('frmTicketCreateFileUpload'); #SUBMIT FORM $mech->form_name('frmTicketCreate'); $mech->field('__EVENTTARGET', 'btnSave_lnkButton'); $mech->submit();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: mechanize submission is all one line and loses line breaks reading input
by Kenosis (Priest) on Sep 21, 2012 at 17:17 UTC | |
by Anonymous Monk on Sep 22, 2012 at 12:20 UTC |
Back to
Seekers of Perl Wisdom