CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Web page stalls on: print "Location:mydomain\n\n"

 



MichaelBluejay
New User

Feb 2, 2013, 12:57 PM

Post #1 of 6 (777 views)
Web page stalls on: print "Location:mydomain\n\n" Can't Post

This works fine:

Quote
#! /usr/bin/perl
print "Location:http://AnyDomainBesidesMyOwn.com/\n\n";
close(STDOUT); close(STDIN); close(STDERR);
[some long process]


But the following way stalls the browser, refusing to redirect until the long process is finished:

Quote
#! /usr/bin/perl
print "Location:http://MyOwnDomain.com/\n\n";
close(STDOUT); close(STDIN); close(STDERR);
[some long process]


The long process can be simulated with: sleep 10;

What the hell?


wickedxter
User

Feb 2, 2013, 4:21 PM

Post #2 of 6 (773 views)
Re: [MichaelBluejay] Web page stalls on: print "Location:mydomain\n\n" [In reply to] Can't Post

is script being run by a web server? what web server is on the other end?


MichaelBluejay
New User

Feb 2, 2013, 4:36 PM

Post #3 of 6 (771 views)
Re: [MichaelBluejay] Web page stalls on: print "Location:mydomain\n\n" [In reply to] Can't Post

Yes, it's being run on my Apache web server.


FishMonger
Veteran / Moderator

Feb 3, 2013, 8:58 AM

Post #4 of 6 (758 views)
Re: [MichaelBluejay] Web page stalls on: print "Location:mydomain\n\n" [In reply to] Can't Post

If you plan on doing additional processing after a redirect, then you need to fork, which you are not doing in the code you posted.


MichaelBluejay
New User

Feb 3, 2013, 10:15 AM

Post #5 of 6 (754 views)
Re: [MichaelBluejay] Web page stalls on: print "Location:mydomain\n\n" [In reply to] Can't Post

(1) Why is it necessary to fork?

(2) The code works fine if I redirect to another domain, just not to my own domain. Should I be forking when redirecting to another domain too, even though it appears to work perfectly without forking?

(3) Does the fact that redirects to another domain work fine suggest that the problem with redirecting within my domain is not a forking problem, but rather something else?

(4) I looked up forking and tried the following code, and now the redirect happens right away, but the forked code doesn't execute (i.e., the file is not created).


Quote
#! /usr/bin/perl

if ($pid = fork) { }
else {
close STDOUT();
open(FILE,'>test.txt');
print FILE time;
close(FILE);
exit(0);
}
print "Location: http://mydomain.com/\n\n";



MichaelBluejay
New User

Feb 4, 2013, 5:58 PM

Post #6 of 6 (732 views)
Re: [MichaelBluejay] Web page stalls on: print "Location:mydomain\n\n" [In reply to] Can't Post

Okay, I can get fork to work if I change STDOUT() to (STDOUT). (Whoops.)

I'm still wondering why I have to fork in the first place. Works fine when I redirect to a different domain. Any ideas?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives