Friends,
I am trying to write a script that will allow me to access a webpage that is protected with Apache Basic Authentication, but I don't know how to pass the username and password to the server from my script:
Here's what happpens when I run it$ cat wwwPerl.pl #!/usr/bin/perl -w use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $url = "http://localhost/testauth/testauth.html"; $mech->get( $url ); print $mech->content();
I know I could use expect, but I don't fell like having to install Tcl right now. I know that WWW::Mechanize::Shell has an auth method. But I would want to automate things later on. Is there a way to automate WWW::Mechanize::Shell? Hmm...$ ./wwwPerl.pl <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>401 Authorization Required</title> </head><body> <h1>Authorization Required</h1> <p>This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.</p> </body></html>
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |