pip has asked for the wisdom of the Perl Monks concerning the following question:

Hello Dear Monks, My question is: Is there possibly a perl script available to access an htaccess protected area? (by having data sent to it by a form input) This would mean to have the username and password added to the address in the browser. I had a look on the web, but could only find some scripts written in php (washing my mouth out with soap right now) Thanks, Pip
  • Comment on Login form to enable access to htaccess area?

Replies are listed 'Best First'.
Re: Login form to enable access to htaccess area?
by scottj (Monk) on Feb 20, 2004 at 08:25 UTC
    From the LWP::UserAgent docs:
    $ua->credentials( $netloc, $realm, $uname, $pass )
    Set the user name and password to be used for a realm. It is often more useful to specialize the get_basic_credentials() method instead.
    I've not tried this, but LWP certainly supports it.
      Hi Scottj, Thank's for your reply, I was kind of hoping I would get by without needing to install modules, due to my hosting facilities. I realize now it's not that simple. pip
Re: Login form to enable access to htaccess area?
by chimni (Pilgrim) on Feb 20, 2004 at 04:26 UTC

    I would think so
    (if i understand your question correctly i.e)
    Try LWP or WWW::Mechanize (modules and docs at cpan.org.
    or you could try wget
    rgds
      Hi Chimni, Thanks for your reply!
Re: Login form to enable access to htaccess area?
by iburrell (Chaplain) on Feb 20, 2004 at 21:38 UTC
    Other people have mentioned how to access password protected pages from a Perl script as a client. Is this what you are asking about? Or do you want a HTML login form and CGI script that provides access to a password protected site? It is possible to have a CGI script redirect to a URL containing the username and password.
    my $url = 'http://' . $username . ':' . $password '@' . 'www.example.c +om/some_page.html'; print $cgi->redirect($url);
    The problems are that this exposes the password in the URL bar. Putting it in frames can make it less obvious but it is still there. Also, a recent update to IE removes all support for usernames and passwords in http URLs. This completely stops any login script from working.
      Note that the above trick also works if you are using LWP::Simple. And the update to IE doesn't affect LWP at all.
        Thanks for your help, Tilly, as mentioned on my other replies, unfortunately I cannot install any modules on my server. pip