Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to redirect url with username/password in perl? 3

Status
Not open for further replies.

alan123

MIS
Oct 17, 2002
149
US
Hi,

I have a question regarding redirect url in perl.
I can use this code to redirect url properly:
====
#!/usr/bin/perl
print "Content-type:application/x-download\n";
$url="print "Location: $url \n\n";
====

it works fine, now I create a folder with .htaccess protected, I have setup username/password in .htpasswd, the url " can reach that protected page without prompt me the box to login, I want to write it in perl so it will login automatically.

However if I try:
====
#!/usr/bin/perl
print "Content-type:application/x-download\n";
$url="print "Location: $url \n\n";
====

It doesn't work and prompt me to enter login info. can anyone help me is it possible to redirect username/password embeded url in perl? thanks in advance.
 
duncdude - I've just asked someone external to check the page and they are getting prompted for a password. Could you have it being entered automatically? The code you supplied does work for me, but only in Opera. The additional problem I'm having is that when I paste that code into my existing script, see above, the whole thing dies again, on Opera and IE.

Thanks for you help, I think we're getting to the problem that the original posting from alan123 was about.
 
Hi Nutthick - this gets even stranger! I've just tried on IE and Safari on OSX (Mac) and i've just realised something. It must have worked as if I type:-


... it prompts me for a username / password

I cannot get past - obviously - unless I type the requested information in the boxes. If I do I get the page with one line of text that says:-

"This is a private page"

It works with both browsers with the URL:-


... what confused me was once I have logged in once it doesn't prompt me again for a login/pass if I type the short URL without the user/pass info

Hope this makes sense!


Kind Regards
Duncan
 
duncdude's redirect works for me (Mozzila FireFox 0.8) - nice work :)

duncdude said:
... what confused me was once I have logged in once it doesn't prompt me again for a login/pass if I type the short URL without the user/pass info

almost all browsers cache http-auth info and automatically resubmit it. The auth cache is usually cleared when you close the browser.

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
thank you manarth!

I was a bit of a plonker not realising about the cache!!!


Kind Regards
Duncan
 
duncdude - When I click on the link I get the IE message 'The Page cannot be displayed'. Just asked someone else in a completely different system to try it and they get a DNS error. However, if I try it in Opera then it redirects me and asks for a username and password.
 
I've now tried it on a few different systems, using the script I posted above. All IE on PCs don't allow anything to be shown. They bring up an error with the script path in the address bar and 'The Page Cannot Be Displayed' in the window. Opera (on three machines) prompts again for a username and password. Now here is the bizarre thing... Safari and IE on OS X work perfectly, they go straight to the private page.

duncdude - What PC browser are you using?
 
In case it helps, I tried it in IE5 on Win2k and got prompted for a uname and password.
 
Hi Nutthick

Guess what... OSX - both Safari and IE work fine

weird...


Kind Regards
Duncan
 
oh, forgot to mention, works fine with IE 5.0 on OS 9.2.2 also!


Kind Regards
Duncan
 
good find philote! I bet quite a few minds are at rest after that!


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top