Link to home
Start Free TrialLog in
Avatar of wspoulin
wspoulin

asked on

Status Code 302

I have two CGI scripts (perl) which are running around behind the scenes calling each other with perl's $query->redirect().  When processing is done, the final redirect to a third file (sh script) produces a Status 302. THe script is there, the URL is correct.  Why can't the server find it?  I'm suspecting it has somehow become confused with all the redirects.  Could it be a problem with
the perl routine?  I will attempt it with straight html. In the meantime any help appreciated!
ASKER CERTIFIED SOLUTION
Avatar of mkornell
mkornell

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wspoulin
wspoulin

ASKER

Mark,
I'm using Netscape 3.0 (Unix and NT).  Does this mean that redirection will not work for me?  It seems odd. The funny part
is that it works on some scripts but not on others. Same permissions, same owners, same redirect call. I just don't
get it!  I will compare a script that works with one that doesnt again.  Any additional thoughts appreciated.

Thanks,Wendy
Netscape 3 certainly supports the <META REFRESH> tag, as does IE 3+.  Don't know about NS2, IE2.

In your Perl code, take care where you place the ->redirect() statement.  For it to work properly, you must not generate the normal header.  (According to the docs, anyways)
use CGI;
$cgi = new CGI;
print $cgi->redirect ("http://...");
#print $cgi->header;    # don't do this...
#print $cgi->start_html;
#print $cgi->end_html;

You could also skip using the CGI module for output and set the "Location" HTTP header directly:

use CGI;
$cgi = new CGI;  #get the input data (form or querystring)print STDOUT "Location: http://...\n\n";
#note, no CGI output statements.

HTH,
--mark;
Oops, need a newline in the last bit:

use CGI;
$cgi = new CGI; #get the input data (form or querystring)
print STDOUT "Location: http://...\n\n";
#note, no CGI output statements.

--mark;

Mark,
 Thankyou!  I had an erroneous print->header at the top of the code.  Works like a charm now!

THanks for the help.
Wendy