forgive the reordering of stuff here.
On Sunday, Jul 27, 2003, at 13:29 US/Pacific, awarsd wrote: [..]
In your code my ($user, $pword) = gbc($realm, $uri); die "No $pword" unless $pword ; $ua->credentials($uri->host_port, $realm, $user, $pword) what is gbc, $realm and $uri pls
the gbc() is actually at the end of the piece of email, see below - you can tailor it as you would prefer - If I remember - I got it originally from doing
perldoc -m LWP::UserAgent
and asking
"What in the wild, wild world of sport is going on here..."
and then followed the comment bar, and simply lifted the original one and edited it as it would come out to be useful for me.
the $uri is well
use URI; $uri = URI->new("$the_url");
cf: perldoc URI
the $realm is really just any string that will be used as a part of stashing it all, since, as you will notice from the
perldoc -m LWP::UserAgent
what we are looking at is code of the form:
@{ $self->{'basic_authentication'}{$netloc}{$realm} } = ($uid, $pass);
if it is any help the ORIGINAL COMMENT I had in the code that I was playing with to deal with all of that asserts: ... if ( $pword ) { # # now what The FreMonge is a $netloc??? # $ua->credentials($uri->host_port, $realm, $user, $pword) ....
now lets move onto the 'first part' of your query:
my question is how to I pass user/passwd info to the pop up box of my MySQL
admin from my personnel computer .
i.e .htaccess have a pop up box requesting user/passwd. but since i will not
be able to get taht pop up window, I need a way for my program to do it.
actually, that IS how you deal with the 'pop up window' { which on some browsers is a 'drop down screen' }
It may help to remember what really goes on in the exchange between the web-browser and the web-server, which is NOT a simple singular request-response event, but a sequence.
what is happening is a sequence of messages
primate <-> browser <-> server click-url -> get foo -> <- get credentials <- ask_primate
fill in pop up -> pass_to_server -> <-return_page_to_browser() <- show_page_to_primate ook-ook
Remember that the server side MAY send a 'page' that is a 'rejection' of the information that one has filled into the pop up - it need not be the 'perferred' page that the primate wanted to see.
But what you do with the lwp user agent approach, which is a command line piece of code then it would be:
<-ask_primate_gbc() poke-poke-> get_foo_with_creds-> <-Happy_server_return_page <- show_page_to_primate ook-ook
This SENDS the credentials along with the request in the HTTP headers that are passed to the web-server - which will then of course notice
a. that there is a .htaccess file b. that there is a 'credential section' in the HTTP header c. IF they resolve, THEN all is golden, and the .htaccess section has been 'validated' and 'satisfied' and the rest of the request is handled as just one more GET|POST request.
Now if one wants this LWP::UserAgent to be run as a cron, the trick is to cache that information, encrypted, and then simply read it back into the code. This of course is why folks have things like
.my_special_file
that are readable only by the user, and tend to have thing that look like GIBBERISH. If you are into Serious XMLing, you can of course make that an actual XML doc, and have the encrypted stuff inside a
<NotFullyGibberish> ,,,,,,,,,,, </NotFullyGibberish>
so that you remind yourself that it is NOT fully gibberish...
oh yes, the original gbc() method from the email...
sub gbc {
my($realm, $uri) = @_; # if ($main::options{'C'}) { # return split(':', $main::options{'C'}, 2); # } elsif (-t) { if(-t) { # are we attached to a tty??? my $netloc = $uri->host_port; print "Enter username for $realm at $netloc: "; my $user = <STDIN>; chomp($user); return (undef, undef) unless length $user; print "Password: "; system("stty -echo"); my $password = <STDIN>; system("stty echo"); print "\n"; # because we disabled echo chomp($password); return ($user, $password); } else { return (undef, undef) }
} # end gbc - the get_basic_credentials
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]