WWW::Mechanize::field problem
I’m having trouble with setting a field on a web page. Here is how I’m attempting to do this: ## ## fourth page ## ok($mech-form_name('ftp_information'),getting the ftp_information form); ok($mech-field('pFTPHostname','dogs'), 'Setting ftp host name to dogs'); ok($mech-field('pFTPUsername','dogs'), 'Setting ftp user name to dogs’); It fails on the pFTPHost name; Here’s the raw html : div id='myForm' span class='required'*/span indicates Required Fieldbr/br/ table border='0' cellpadding='3' cellspacing='0' width='100%' form name='ftp_information' method='POST' action='file_admin.cgi' input type='hidden' name='rm' value='process_ftp_information' input type='hidden' name='CGISESSID' value='d02df1fb65eb3b2058770f5e395f1451' input type='hidden' name='ftp_information' value='1' tr td class='fieldLabel' width='45%' FTP Hostname or IP Address: /td td class='field' input type='text' class='text' name='pFTPHostname' value='' span class='required' */span /td /tr tr td class='fieldLabel' FTP Username: /td td class='field' input type='text' class='text' name='pFTPUsername' value='' span class='required' */span /td /tr tr td class='fieldLabel' FTP Password: /td td class='field' input type='text' class='text' name='pFTPPassword' value='' span class='required' */span /td /tr tr td colspan='2' align='center'br/input type='submit' value='Continue' class='button'/td /tr /form /table /div The form : $VAR1 = bless( { 'accept_charset' = 'UNKNOWN', 'action' = bless( do{\(my $o = 'http://cportal-test.dfw0.hypercube-llc.com/html/file_admin.cgi')}, 'URI::http' ), 'attr' = { 'method' = 'POST', 'name' = 'ftp_information' }, 'default_charset' = 'UTF-8', 'enctype' = 'application/x-www-form-urlencoded', 'inputs' = [ bless( { 'name' = 'rm', 'readonly' = 1, 'type' = 'hidden', 'value' = 'process_ftp_information', 'value_name' = '' }, 'HTML::Form::TextInput' ), bless( { 'name' = 'CGISESSID', 'readonly' = 1, 'type' = 'hidden', 'value' = '3facae5659bca900e5ef3d6c302aad4e', 'value_name' = '' }, 'HTML::Form::TextInput' ), bless( { 'name' = 'ftp_information', 'readonly' = 1, 'type' = 'hidden', 'value' = '1', 'value_name' = '' }, 'HTML::Form::TextInput' ), bless( { 'class' = 'text', 'name' = 'pFTPHostname', 'type' = 'text', 'value' = '', 'value_name' = '*' }, 'HTML::Form::TextInput' ), bless( { 'class' = 'text', 'name' = 'pFTPUsername', 'type' = 'text', 'value' = '', 'value_name' = '*' }, 'HTML::Form::TextInput' ), bless( { 'class' = 'text', 'name' = 'pFTPPassword', 'type' = 'text', 'value' = 'cats', 'value_name' = '*' }, 'HTML::Form::TextInput' ), bless( { 'class' = 'button', 'type' = 'submit', 'value' = 'Continue', 'value_name' = '' }, 'HTML::Form::SubmitInput' ) ], 'method' = 'POST' }, 'HTML::Form' );
Re: At wits end CGI
CGI::Application.pm is version 4.5 Somehow I’ve managed to move beyond this problem. Probably because I dumped perlbrew. I’m now getting a time out. With traces and multiple debug statements I’m getting to this location for the time out: sub AUTOLOAD { my($constname); ($constname = $AUTOLOAD) =~ s/.*:://o; $! = 0; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { croak Your vendor has not defined Socket macro $constname, used; } eval sub $AUTOLOAD { $val }; goto $AUTOLOAD; } This is from file /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level/Socket6.pm I hit this inside the debugger. The code below is from my module that inherits CGI::Application. From some reason I don’t understand it calls CGI::Application::Plugin::TT::import the first thing. I can’t find where that is coming from. Why is it calling this before it even calls the “new” in Application.pm warn Got to here : . __FILE__ . ':'.__LINE__.\n; use strict; use base 'CGI::Application'; warn Got to here : . __FILE__ . ':'.__LINE__.\n; use CGI::Application::Plugin::TT; # Template Toolkit use CGI::Application::Plugin::DBH (qw/dbh_config dbh/); # Database handles On Nov 25, 2014, at 10:29 AM, John SJ Anderson geneh...@genehack.orgmailto:geneh...@genehack.org wrote: What version of CGI::Application do you have installed? 4.5 Assuming the most recent one (https://metacpan.org/source/MARKSTOS/CGI-Application-4.50/lib/CGI/Application.pm), line 1951 is: if ( $p{path_info} $self-query-path_info() ) { $self-query calls the 'query' method, defined at line 493. I'm guessing code flow goes into the 'else' half of the branch there, and ends up calling $self-cgiapp_get_query() (on line 503). That method is defined at line 250, and ultimately returns the result of calling CGI-new(). I would suggest either putting in some debug print() statements into that cgiapp_get_query() routine, or using the debugger to stop execution inside there and looking at what that call from CGI-new() is actually returning. chrs, john. On Tue, Nov 25, 2014 at 7:56 AM, Patton, Billy N billy.pat...@h3net.commailto:billy.pat...@h3net.com wrote: OS : mac 10.10.1 Yosemite Perl version : 5.16.0 (perlbrew) I have file cp.cgi that is the top level It uses CP.pm which inherits Base.pm which inherits CGI::Application CGI::Application Requires CGI.pm CGI.pm has a use CGI::Util qw(… unescape …); When I try and run cp.cgi I get a timeout. The erro log only tells me that I get a timeout [Tue Nov 25 09:13:53.677383 2014] [cgi:warn] [pid 461] [client ::1:63053] AH01220: Timeout waiting for output from CGI script /Library/WebServer/Documents/cportal/html/cp.cgi, referer: http://localhost/index.html when I try and run it from the command line : perl cp.cgi I get h1Software error:/h1 preUndefined subroutine CGI::unescape at /Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm line 1951. /pre p For help, please send mail to this site's webmaster, giving this error message and the time and date of the error. /p [Tue Nov 25 09:34:59 2014] cp.cgi: Undefined subroutine CGI::unescape [Tue Nov 25 09:34:59 2014] cp.cgi: at /Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm line 1951. unescape exists in CGI::Util.pm and is exported. When I put a Dumper \%INC I get: Making sure that I wasn’t mixing too many version 'CGI/Application.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm’, 'CGI/Application/Plugin/Redirect.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Redirect.pm', 'CGI/Application/Plugin/TT.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/TT.pm’, 'CGI/Application/Plugin/ValidateRM.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/ValidateRM.pm’, 'CGI/Application/Plugin/LogDispatch.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/LogDispatch.pm', 'CGI/Carp.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Carp.pm’, 'CGI/Application/Plugin/Config/YAML.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Config/YAML.pm', 'CGI/Application/Plugin/DBH.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/DBH.pm’, 'CGI/Util.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Util.pm’, 'CGI/Application/Plugin/Forward.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Forward.pm’, unescape does not exist in Application, even though it tells me line 1951 %INC shows me that it is including the right file. Util.pm is exporting package CGI::Util; use base 'Exporter'; require 5.008001; use
At wits end CG::unescape
OS : mac 10.10.1 Yosemite Perl version : 5.16.0 (perlbrew) I have file cp.cgi that is the top level It uses CP.pm which inherits Base.pm which inherits CGI::Application CGI::Application Requires CGI.pm CGI.pm has a use CGI::Util qw(… unescape …); When I try and run cp.cgi I get a timeout. The erro log only tells me that I get a timeout [Tue Nov 25 09:13:53.677383 2014] [cgi:warn] [pid 461] [client ::1:63053] AH01220: Timeout waiting for output from CGI script /Library/WebServer/Documents/cportal/html/cp.cgi, referer: http://localhost/index.html when I try and run it from the command line : perl cp.cgi I get h1Software error:/h1 preUndefined subroutine CGI::unescape at /Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm line 1951. /pre p For help, please send mail to this site's webmaster, giving this error message and the time and date of the error. /p [Tue Nov 25 09:34:59 2014] cp.cgi: Undefined subroutine CGI::unescape [Tue Nov 25 09:34:59 2014] cp.cgi: at /Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm line 1951. unescape exists in CGI::Util.pm and is exported. When I put a Dumper \%INC I get: Making sure that I wasn’t mixing too many version 'CGI/Application.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm’, 'CGI/Application/Plugin/Redirect.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Redirect.pm', 'CGI/Application/Plugin/TT.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/TT.pm’, 'CGI/Application/Plugin/ValidateRM.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/ValidateRM.pm’, 'CGI/Application/Plugin/LogDispatch.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/LogDispatch.pm', 'CGI/Carp.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Carp.pm’, 'CGI/Application/Plugin/Config/YAML.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Config/YAML.pm', 'CGI/Application/Plugin/DBH.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/DBH.pm’, 'CGI/Util.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Util.pm’, 'CGI/Application/Plugin/Forward.pm' = '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Forward.pm’, unescape does not exist in Application, even though it tells me line 1951 %INC shows me that it is including the right file. Util.pm is exporting package CGI::Util; use base 'Exporter'; require 5.008001; use strict; use if $] = 5.019, 'deprecate'; our @EXPORT_OK = qw(rearrange rearrange_header make_attributes unescape escape expires ebcdic2ascii ascii2ebcdic); our $VERSION = '4.09’;
Re: CGI::Application::Plugin::TT
Doing the perlbrew thing now. perl -MTemplate -e 1 returned nothing But I did a sudo cpan Template and it told me it was up to date. Hopefully this perlbrew will help things out. thanks for the info. On Nov 12, 2014, at 8:50 AM, John SJ Anderson geneh...@genehack.orgmailto:geneh...@genehack.org wrote: perl -MTemplate -e 1 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
CGI::Application::Plugin::TT
I’ve , mistakenly, updated to Mac OS 10.10 Yosemite. That completely caused my app to fail in Apache 2.4. Looks like it might be a version problem for TT.pm I’ve tried to install a new TT.pm from cpan but it tells me that it is up to date. I’ve tried changing the Template-new to HTML::Template- new with bad results. I’ve tried changing use Template to use HTML::Template with bad results I’ve tried changing the use Template 2.0; to use Template. results are still it fails; It looks like MAC 10.10 was released with a bunch of incompatible versions of perl modules. What can I do? The error I’m getting is : Can't locate object method new via package Template at /Library/Perl/5.18/CGI/Application/Plugin/TT.pm line 60. TT.pm snippett : use Template 2.0; ... # Get a Template Toolkit object. The same object # will be returned everytime this method is called # during a request cycle. # sub tt_obj { my $self = shift; my ($tt, $options, $frompkg) = _get_object_or_options($self); if (!$tt) { my $tt_options = $options-{TEMPLATE_OPTIONS}; if (keys %{$options-{TEMPLATE_OPTIONS}}) { $tt = Template-new( $options-{TEMPLATE_OPTIONS} ) || carp Can't load Template; } else { $tt = Template-new || carp Can't load Template; } _set_object($frompkg||$self, $tt); } return $tt; } ... - HTML/Template.pm $HTML::Template::VERSION = '2.95’; sub new { my $pkg = shift; my $self; { my %hash; $self = bless(\%hash, $pkg); } ...
using string as module
I currently have something like this use MyFoo::ABCBar; use MyFoo::DEFBar; use MyFoo::HIJBar; my $fooABC = MyFoo::ABCBar-new(); … What I would like to do is foreach $pgm ( ‘ABC’ , ‘DEF’ , ‘HIJ’) { my $foo = MyFoo::{$pgm}Bar-new; … } This gives me an error. What is the correct syntax?
Testing my CGI
I’m using WWW::Mechanize for testing my CGI. I’m having trouble with the $mech-tick Here’s my code : ok($mech-form_name('cdr_format'),getting form cdr_format); print pAllFields = . $mech-value('pAllFields') . \n; 219- ok($mech-tick('pAllFields',1), 'Setting checkbox to native CDR format'); 220- ok($mech-tick('pAllFields’,0), 'Setting checkbox to native CDR format’); Here’s a snippet of the html : div id='myForm' form name='cdr_format' method='POST' action='file_admin.cgi' input type='hidden' name='rm' value='process_cdr_format' input type='hidden' name='CGISESSID' value='ec4c3463d5a7f9d04d2924968413f240' input type='hidden' name='cdr_format' value='1' table border='0' cellpadding='3' cellspacing='0' width='100%' tr td class='fieldLabel' width='60%' We would like the files in native CDR format: /td td class='field' input type='checkbox' class='checkbox' name='pAllFields' value='1' /td /tr When I execute I get this : ok 40 - getting form cdr_format Use of uninitialized value in concatenation (.) or string at ./test_cportal.pl line 218. pAllFields = not ok 41 - Setting checkbox to native CDR format # Failed test 'Setting checkbox to native CDR format' # at ./test_cportal.pl line 219. not ok 42 - Setting checkbox to native CDR format # Failed test 'Setting checkbox to native CDR format' # at ./test_cportal.pl line 220. Here’s the documentation from WWW::Mechanize $mech-tick( $name, $value [, $set] ) Ticks the first checkbox that has both the name and value associated with it on the current form. Dies if there is no named check box for that value. Passing in a false value as the third optional argument will cause the checkbox to be unticked.
WWW::Mechanize question
I’ve inherited an app that uses templates. Most of the template contain multiple forms and tables within and buttons within that. The order of the forms I can get from the template, most are not named forms so I have to get them with form_number(#) Question: Can I depend on the form number being the same each time it is loaded? Or will it change.
Re: WWW::Mechanize question
Thanks, Some times it is conditional, depending on admin rights. But your right I should add a name to each of them, it would make things much easier. Just can’t do it to the current production version. Guess I need to make copy and test that one :) On Nov 3, 2014, at 8:50 AM, John SJ Anderson geneh...@genehack.org wrote: Hi Billy - Are any of the forms in the templates displayed conditionally? (I.e., are there forms inside IF blocks in the templates.) If not -- if all the forms are always shown -- then yes, the numbers should be stable. My suggestion would be to just add unique identifiers to the forms, because then you won't have to worry about it. chrs, john. On Mon, Nov 3, 2014 at 6:41 AM, Patton, Billy N billy.pat...@h3net.com wrote: I’ve inherited an app that uses templates. Most of the template contain multiple forms and tables within and buttons within that. The order of the forms I can get from the template, most are not named forms so I have to get them with form_number(#) Question: Can I depend on the form number being the same each time it is loaded? Or will it change.
Re: WWW::Mechanize question
I’ve gotten everything copied and working from the Chrome, but when I execute my test script I get : ok 1 - In sub main::login ok 2 -: 49 : Credentials passed ok Error GETing http://cportal-test.dfw0.hypercube-llc.com/html/cp.cgi: Authorization Required at /System/Library/Perl/Extras/5.18/LWP/Authen/Basic.pm line 56. Here is my .htaccess : AuthType Basic AuthName HyperCube Customer Portal requires a username and password AuthUserFile /var/www/passwords/cportal.passwd Require valid-user login/password is the same for all versions. I know it is something just one step away, can’t get what it is? On Nov 3, 2014, at 8:50 AM, John SJ Anderson geneh...@genehack.org wrote: Hi Billy - Are any of the forms in the templates displayed conditionally? (I.e., are there forms inside IF blocks in the templates.) If not -- if all the forms are always shown -- then yes, the numbers should be stable. My suggestion would be to just add unique identifiers to the forms, because then you won't have to worry about it. chrs, john. On Mon, Nov 3, 2014 at 6:41 AM, Patton, Billy N billy.pat...@h3net.com wrote: I’ve inherited an app that uses templates. Most of the template contain multiple forms and tables within and buttons within that. The order of the forms I can get from the template, most are not named forms so I have to get them with form_number(#) Question: Can I depend on the form number being the same each time it is loaded? Or will it change.