redirect location prints to screen 
Author Message
 redirect location prints to screen

I have written a cgi that uses an environment variable (remote_user)
on a password protected page to redirect the user to one of several
folders, each named after on of the likely users.  The purpose is to
have a link to a client access area where each client can 'sign in'
and be directed to their own private page.

The problem: when the cgi executes it generates a hyperlink printed at
the the top of an otherwise blank page.  When clicked, the hyperlink
will take the user to the correct page, but that is not the effect
that I wish to achieve.  I had hoped to have the redirect print to the
location bar and not the page.  The cgi is being executed from a shtml
page.  What am I doing wrong?  Here is the cgi code:

#!/usr/bin/perl
$baseurl = ' http://www.*-*-*.com/ ';
$user = $ENV{'REMOTE_USER'};
$fullurl = $baseurl.lc($user);
print "Location: $fullurl/\n\n";

Thanks for any help.



Mon, 21 Nov 2005 21:28:59 GMT  
 redirect location prints to screen

(snipped)

Quote:
> The problem: when the cgi executes it generates a hyperlink printed at
> the the top of an otherwise blank page.

This is impossible. Your code contains no html hyperlink tags.

Quote:
> When clicked, the hyperlink will take the user to the correct page,

This is impossible. Your code contains no html hyperlink tags.

Quote:
> I had hoped to have the redirect print to the location bar and not the page.

With correct data, it does.

Quote:
> What am I doing wrong?

Not writing an article which is clear, concise and coherent.

Do you need a tilde in front of your user name, by chance?

Quote:
> #!/usr/bin/perl
> $baseurl = 'http://www.economicsgroup.com/clients/';
> $user = $ENV{'REMOTE_USER'};
> $fullurl = $baseurl.lc($user);
> print "Location: $fullurl/\n\n";

Purl Gurl


Mon, 21 Nov 2005 21:59:08 GMT  
 redirect location prints to screen


Quote:
> I have written a cgi that uses an environment variable (remote_user)
> on a password protected page to redirect the user to one of several
> folders, each named after on of the likely users.  The purpose is to
> have a link to a client access area where each client can 'sign in'
> and be directed to their own private page.

> The problem: when the cgi executes it generates a hyperlink printed at
> the the top of an otherwise blank page.  When clicked, the hyperlink
> will take the user to the correct page, but that is not the effect
> that I wish to achieve.  I had hoped to have the redirect print to the
> location bar and not the page.  The cgi is being executed from a shtml
> page.  What am I doing wrong?  Here is the cgi code:

> #!/usr/bin/perl
> $baseurl = 'http://www.economicsgroup.com/clients/';
> $user = $ENV{'REMOTE_USER'};
> $fullurl = $baseurl.lc($user);
> print "Location: $fullurl/\n\n";

> Thanks for any help.

you can't do that from an ssi - by the time it's executed, the http
headers have already been completed - hence the link appearing on the
page... you'll have to use a perl script, or php, or...

--
Michael Budash



Mon, 21 Nov 2005 22:33:08 GMT  
 redirect location prints to screen

Quote:

> I have written a cgi that uses an environment variable (remote_user)
> on a password protected page to redirect the user to one of several
> folders, each named after on of the likely users.  The purpose is to
> have a link to a client access area where each client can 'sign in'
> and be directed to their own private page.

> The problem: when the cgi executes it generates a hyperlink printed at
> the the top of an otherwise blank page.  When clicked, the hyperlink
> will take the user to the correct page, but that is not the effect
> that I wish to achieve.  I had hoped to have the redirect print to the
> location bar and not the page.  The cgi is being executed from a shtml
> page.  What am I doing wrong?  Here is the cgi code:

> #!/usr/bin/perl
> $baseurl = 'http://www.economicsgroup.com/clients/';
> $user = $ENV{'REMOTE_USER'};
> $fullurl = $baseurl.lc($user);
> print "Location: $fullurl/\n\n";

Hey, correct me if I'm wrong, but that doesn't look like a CGI script.
It is just an ordinary perl script doing ordinary perl stuff.

#!/usr/bin/perl
$baseurl = 'http://www.economicsgroup.com/clients/';
$user = $ENV{'REMOTE_USER'};
$fullurl = $baseurl.lc($user);
print "Location: $fullurl/\n\n";

All you've done is created three variables and printed a line to
standard output.

And from the sounds of things, that exactly what you have described as
the result of running this script.  I'd like to help you with some real
code, but CGI scripting is not my expertise.  Maybe another reader can help.

Good luck



Tue, 22 Nov 2005 12:05:37 GMT  
 redirect location prints to screen

Quote:


>> I have written a cgi that uses an environment variable (remote_user)
>> on a password protected page to redirect the user to one of several
>> folders, each named after on of the likely users.  The purpose is to
>> have a link to a client access area where each client can 'sign in'
>> and be directed to their own private page.

>> The problem: when the cgi executes it generates a hyperlink printed at
>> the the top of an otherwise blank page.  When clicked, the hyperlink
>> will take the user to the correct page, but that is not the effect
>> that I wish to achieve.  I had hoped to have the redirect print to the
>> location bar and not the page.  The cgi is being executed from a shtml
>> page.  What am I doing wrong?  Here is the cgi code:

>> #!/usr/bin/perl
>> $baseurl = 'http://www.economicsgroup.com/clients/';
>> $user = $ENV{'REMOTE_USER'};
>> $fullurl = $baseurl.lc($user);
>> print "Location: $fullurl/\n\n";

> Hey, correct me if I'm wrong, but that doesn't look like a CGI script.
> It is just an ordinary perl script doing ordinary perl stuff.

> #!/usr/bin/perl
> $baseurl = 'http://www.economicsgroup.com/clients/';
> $user = $ENV{'REMOTE_USER'};
> $fullurl = $baseurl.lc($user);
> print "Location: $fullurl/\n\n";

> All you've done is created three variables and printed a line to
> standard output.

> And from the sounds of things, that exactly what you have described as
> the result of running this script.  I'd like to help you with some real
> code, but CGI scripting is not my expertise.  Maybe another reader can
> help.

> Good luck

Having said that...  I've managed to get something... hope it helps

#!/usr/bin/perl
use strict;
use warnings;

use CGI;

my $baseurl = 'http://www.economicsgroup.com/clients/';
my $user = $ENV{'REMOTE_USER'};
my $fullurl = $baseurl.lc($user);
#print "Location: $fullurl/\n\n";

my $co = new CGI;

print(
       "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=$fullurl/index.html'>",
       $co->start_html(),
       $co->end_html
      );



Tue, 22 Nov 2005 12:51:25 GMT  
 redirect location prints to screen
Hi,

 > What am I doing wrong?  Here is the cgi code:

Quote:

> #!/usr/bin/perl
> $baseurl = 'http://www.economicsgroup.com/clients/';
> $user = $ENV{'REMOTE_USER'};
> $fullurl = $baseurl.lc($user);
> print "Location: $fullurl/\n\n";

Works perfectly for me.

What Webserver / Browser are you using?



Tue, 22 Nov 2005 12:53:19 GMT  
 redirect location prints to screen

Quote:

> Hi,

>  > What am I doing wrong?  Here is the cgi code:

> > #!/usr/bin/perl
> > $baseurl = 'http://www.economicsgroup.com/clients/';
> > $user = $ENV{'REMOTE_USER'};
> > $fullurl = $baseurl.lc($user);
> > print "Location: $fullurl/\n\n";

> Works perfectly for me.

> What Webserver / Browser are you using?

Thanks for all of the suggestions, but so far none of them have worked
on my site.  The mechanics of website may be responsible for the
problem.  I have a root index page that contains a 'client' link.
That link goes to a client folder which contains several subfolders
each of which is named after a client.

Those subfolders are password protected and the username for each is
the name of their folder.  Within the client folder is also an
index.shtml page that contains the call to the CGI script.  I need to
have this call from within the client folder in order for the
username/password prompt to be executed PRIOR to calling the CGI
script.  I do that in order to record the username response as an
environment variable (REMOTE_USER).  To see how this currently works
visit my site: www.economicsgroup.com and test the client access link.
 A test username and password is ahm/ron.  What I have is a reasonable
workaround but I was hoping to find a way to avoid the intermediate
page with the hypertext that reads
'http://www.economicsgroup.com/clients/ahm/'.

BTW I am running this on a unix box.  Thanks again for your
suggestions.



Wed, 23 Nov 2005 01:36:16 GMT  
 redirect location prints to screen
On Sat, Jun 6, Harvey Siegelman inscribed on the eternal scroll:

Quote:
> Thanks for all of the suggestions, but so far none of them have worked
> on my site.

I've already seen the answer posted.  Either you didn't read it, or
you failed to recognise it as the answer.

Quote:
> The mechanics of website may be responsible for the problem.

The fact that you're using SSI makes it impossible to achieve what you
intend.

Quote:
> Those subfolders are password protected and the username for each is
> the name of their folder.  Within the client folder is also an
> index.shtml page that contains the call to the CGI script.

So don't do that.  And this has nothing specific to do with Perl.

What persuaded you to add the extra complication and difficulty of
putting an SSI in front of your CGI?

Quote:
> BTW I am running this on a unix box.

Irrelevant.  The chief benefit of CGI is that it's designed to be
portable.

And whoever suggested that your browser might be an issue, didn't
understand the principles either.  If you send the right response,
then all client agents will understand it correctly.  If you send the
wrong response (and you did), then fiddling around with the client
agent is no solution.

cheers

--

      ISO-8859-1 is one of two charsets appropriate for use in
      Western Europe (the other is ISO-8859-15).  The US has not
      been politically part of Europe for nearly 227 years.  - Mark Crispin



Wed, 23 Nov 2005 12:07:07 GMT  
 redirect location prints to screen

Quote:



>>> I have written a cgi that uses an environment variable (remote_user)
>>> on a password protected page to redirect the user to one of several
>>> folders, each named after on of the likely users.  The purpose is to
>>> have a link to a client access area where each client can 'sign in'
>>> and be directed to their own private page.

>>> The problem: when the cgi executes it generates a hyperlink printed at
>>> the the top of an otherwise blank page.  When clicked, the hyperlink
>>> will take the user to the correct page, but that is not the effect
>>> that I wish to achieve.  I had hoped to have the redirect print to the
>>> location bar and not the page.  The cgi is being executed from a shtml
>>> page.  What am I doing wrong?  Here is the cgi code:

>>> #!/usr/bin/perl
>>> $baseurl = 'http://www.economicsgroup.com/clients/';
>>> $user = $ENV{'REMOTE_USER'};
>>> $fullurl = $baseurl.lc($user);
>>> print "Location: $fullurl/\n\n";

>> Hey, correct me if I'm wrong, but that doesn't look like a CGI script.
>> It is just an ordinary perl script doing ordinary perl stuff.

>> #!/usr/bin/perl
>> $baseurl = 'http://www.economicsgroup.com/clients/';
>> $user = $ENV{'REMOTE_USER'};
>> $fullurl = $baseurl.lc($user);
>> print "Location: $fullurl/\n\n";

>> All you've done is created three variables and printed a line to
>> standard output.

>> And from the sounds of things, that exactly what you have described as
>> the result of running this script.  I'd like to help you with some real
>> code, but CGI scripting is not my expertise.  Maybe another reader can
>> help.

>> Good luck

>Having said that...  I've managed to get something... hope it helps

>#!/usr/bin/perl
>use strict;
>use warnings;

>use CGI;

>my $baseurl = 'http://www.economicsgroup.com/clients/';
>my $user = $ENV{'REMOTE_USER'};
>my $fullurl = $baseurl.lc($user);
>#print "Location: $fullurl/\n\n";

>my $co = new CGI;

>print(
>       "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=$fullurl/index.html'>",
>       $co->start_html(),
>       $co->end_html
>      );

CAT:
BLESS YOUR SOUL!!! I AM IN YOUR DEBT FOR AT LEAST THIS WEEKEND. I HAD THE SAME PROBLEM AND THIS SOLVED IT.
THANK YOU THANK YOU THANK YOU!!


Wed, 30 Nov 2005 06:05:02 GMT  
 redirect location prints to screen

[...vast over-quotage snipped...]

Quote:
> >       "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=$fullurl/index.html'>",

Garbage.  A pathetic ersatz for a real redirection.

Quote:
> CAT:
> BLESS YOUR SOUL!!! I AM IN YOUR DEBT FOR AT LEAST THIS WEEKEND. I HAD THE SAME PROBLEM AND THIS SOLVED IT.
> THANK YOU THANK YOU THANK YOU!!

My weekend has been saddened.  But this is off-topic for Perl.  You'd
do well to find a real WWW usenet group.


Wed, 30 Nov 2005 10:46:08 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. print Location and print "Location

2. Main window location on the screen

3. Location Redirect (newbie help question)

4. redirect location frames help

5. Redirect to Location:

6. redirect screen output

7. print "Location: erratic ???????????

8. print "Location: http://..." avec param├Ętres

9. simple print location and content-type?

10. print: location not working?

11. print "Location: $filename\n\n";

12. print "Location: revised

 

 
Powered by phpBB® Forum Software