Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Redirecting from a scipt to another script

( #31221=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Sep 06, 2000 at 14:12 UTC
Q&A  > CGI programming


Description:

Hello, I have a form which calls perl script "a.pl". This script does some managerial tasks and then sends a redirection back to the browser. Although, this redirection is the path to another perl script "b.pl" which produces some output to the user. The problem is that even though script "b" gets accessed (it is on a protected area so i can see the authentication box poping up) it never returns any output. Actually, the browser waits indefinetelly till i get an IO timeout. What's the correct method of redirecting from a script to another script?

Note1: I've even tried puting "b" in the same (non-protected) area as script "a" but i get the same result.
Note2: Script "b" itself (i.e. calling it directly) produces the expected output.

Note3: My server's error log:
[06/Sep/2000:12:45:53] warning (22941): for host 10.xxx.xxx.xxx trying + to GET /cgi/b.pl, start-http-response reports: write failed (Broken +p ipe) [06/Sep/2000:12:45:53] warning (22941): for host 10.xxx.xxx.xxx trying + to GET /cgi/b.pl, start-http-response reports: write failed (Broken +p ipe) [06/Sep/2000:12:48:39] failure (22941): for host 10.xxx.xxx.xxx trying + to GET /cgi/b.pl, cgieng_send_content reports: error occurred while +sending content to script (IO timeout error)
Any help really appreciated!
-n-

Answer: Redirecting from a scipt to another script
contributed by jreades

I can make a few suggestions for exploration:

  1. If you want to do this via browser redirect are you sure that the script is exiting cleanly -- this is in line with what the Anonymous Monk suggested, but I'd definitely go with trying the redirect as the last line before exit 0;.

  2. This might also be a candidate for an exec() -- rather than redirecting to the new script, launch the script 'b' from within script 'a'. There was a good thread (at least, I sure learned a lot) just a couple of weeks back. You can read it here (the thread thread picks up about midway down and I'd particularly recommend: tilly's piece and that from geeksalad.

I also find it helpful to use the following line when debugging scripts that are on a server:

BEGIN { $| = 1; open(STDERR, ">&STDOUT"); print "Content-Type: text/pl +ain\n\n"; }

This nice snippet redirects STDERR to STDOUT and prints everything as text/plain to the browser -- then you can use your standard print $whatever . "\n"; while debugging.

Answer: Redirecting from a scipt to another script
contributed by Anonymous Monk

Have you closed STDOUT and SDTERR on 'a.pl' before redirecting to 'b.pl'? The server may be waiting for those file handles to close on 'a.pl'.

Answer: Redirecting from a scipt to another script
contributed by Anonymous Monk

The problem also occured for me on an iPlanet Web Server, while Apache had no problem with the redirect.

I was redirecting to a relative url like: /cgi-bin/burp.pl

Changing this to http://my.webserver.com/cgi-bin/burp.pl

Solved it...

Hope this helps!

Michiel Toneman (michiel@apenstaartje.REMVE.nl)

Answer: Redirecting from a scipt to another script
contributed by mhi

The problem seems to have something to do with the new line of Netscape/Mozilla clients (since around Netscape 4.7).

I have had a perl cgi application running on a Netscape Fasttrack Server 3.01 (a forerunner of the iPlanet-Servers) on HP-UX 10.20 (now 11.0) since 1998 and it never did this kind of thing with the old browsers.

By analyzing the logs and results from debugging code I was astonished to find that everything was actually going as expected: cgi a was executed, the browser received the redirect, called cgi b, which was executed and completed. But still I kept getting core files, no output in the browser and logs of TIMEOUTS or PREMATURE EOFs as seen below until I changed from relative to absolute URLs as described by Michiel above.

[25/Oct/2002:20:46:16] failure: for host 141.36.65.205 trying to GET / +cgi-bin/fw/fw_ordner.pl, send-cgi reports: error occurred while sendi +ng content to script (IO timeout error) [28/Oct/2002:10:49:57] failure: for host 141.36.65.205 trying to GET / +cgi-bin/fw/fw_ordner.pl, send-cgi reports: error occurred while sendi +ng content to script (premature EOF)
This is very strange.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (9)
    As of 2014-07-28 20:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (209 votes), past polls