simple perl ?

Hi,

I have a script to ask a user for a password which works fine if the user types the right password the script will continue.  My problem is I want the script to send the user to a new web page if they type in the correct password how can I do this?
Right now my script just prints out the link.  I want it to execute the link so the user doesn't have to click on the link.  Really it doesn't need to print anything.

Thanks for any help

Here is my script

#!/usr/bin/perl
require "pass-lib.pl";
&Passlib::Login("magic");

print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<TITLE>Password Test</TITLE>";
print "</HEAD>";
print 'Okay to goto <A HREF="http://xyz/~paul">Paul\'s Home Page</A>.';


LVL 1
onestarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dougisCommented:
this will display the page on the screen for the user however the location will still show the cgi call, is this what you were after?
#!/usr/bin/perl
require "pass-lib.pl";
&Passlib::Login("magic");

print "Content-type: text/html\n\n";
$filepath = "The path to the file you want goes here";
&display_file($filepath);
exit(1);

sub display_file
{
    local ($filename) = @_;
    local ($msgrecs,$rec);
    open(FN,$filename) || die "display_file can't open file $filename";
    @msgrecs=<FN>;
    close(FN);
    foreach $rec (@msgrecs)
    {
         print "$rec";
    }
    return(1);
}
0
onestarAuthor Commented:
That is close.  I don't care if it says the location at the top.  Sorry if I miss led you.  I was just saying my script prints something on the screen and then new script doesn't need to output anything to the screen.

The problem with your answer is it works for a file but not for a web page address.  
$filepath = "The path to the file you want goes here";

For example this will not work and this is what I need to work:

$filepath = "http://www.sgi.com";

How can I get this to work?
0
dougisCommented:
so you are trying to send the user to a file that is not on your server?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

onestarAuthor Commented:
The file will probably be on my server in this case but in general and for furture reference I would like it to be able to go anywhere.  Even if the file is on my server I still can't type http://myserver/~username
0
ozoCommented:
print "Status: 302 Moved\nLocation: http://myserver/~username\n\n";
#instead of
#print "Content-type: text/html\n\n";
#or
use LWP::Simple;
0
dougisCommented:
No you can't that is why I said the PATH to the file and not the URL the path would be something like C:\Data\~username\sharedfile.htm
However another way to do this is to use a meta tag

<meta http-equiv="refresh" content="0; url="http://myserver/~username">

so the script looks like this
#!/usr/bin/perl
require "pass-lib.pl";
&Passlib::Login("magic");

print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<TITLE>Password Test</TITLE>";
print "<meta http-equiv\=\"refresh\" content\=\"0; url=http://xyz/~paul\">";
print "</HEAD>";
print 'Okay to goto <A HREF="http://xyz/~paul">Paul\'s Home Page</A>.';
This will redirect the browser to the new URL


0
onestarAuthor Commented:
dougis your script works fine now thanks
ozo your one line also work fine.
0
onestarAuthor Commented:
I would like to give the points for this questions if you would answer it.
0
dougisCommented:
Here you go

<meta http-equiv="refresh" content="0; url="http://myserver/~username">

so the script looks like this
#!/usr/bin/perl
require "pass-lib.pl";
&Passlib::Login("magic");

print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<TITLE>Password Test</TITLE>";
print "<meta http-equiv\=\"refresh\" content\=\"0; url=http://xyz/~paul\">";
print "</HEAD>";
print 'Okay to goto <A HREF="http://xyz/~paul">Paul\'s Home Page</A>.';
This will redirect the browser to the new URL


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.