in reply to Re^2: Keep running script but ending it to the browser
in thread Keep running script but ending it to the browser

Never thought of that JavaFan.

OK, how's about...

END { system "nohup sleep 5 ; rm $tempfile >/dev/null 2>&1 &"; }
or similar ...

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^4: Keep running script but ending it to the browser
by cowgirl (Acolyte) on Aug 07, 2008 at 17:59 UTC
    Thanks. I am now using your suggestion:
    END { system "nohup sleep 15 ; echo test >/dev/null 2>&1 &"; }
    However inside the shell if the script is executed, it ends succesfully but then waits for 15 seconds before returning to the shell. Inside the browser the same thing happens, exactly 15 seconds after requesting the page, the page is returned. To see the problem I have added a time counter and the runtime is only around 0.2 seconds but it takes 15.2 in reality. Am I implementing the code wrong?
      No probs.

      It shouldn't do that ...

      1. The last & on the line puts the command (sleep 15 ; rm $tempfile >/dev/null 2>&1) into background
      2. nohup (short for, AFAIR, 'no hangup') 'informs' the scheduler that the background shell is to run to completion i.e. not to be terminated, when its controlling process (in this case, the perl script) terminates.

      You might want to 'play around' with the quoting, e.g....

      system "nohup 'sleep 15 ; rm $tempfile 2>&1' &";
      The variable _will_ be interpolated because the single quotes are part of a double quoted string :-)

      HTH ,

      A user level that continues to overstate my experience :-))