in reply to Trigger perl scrip remotely using http

#!/usr/bin/perl use strict; use warnings; $SIG{CHLD} = 'IGNORE'; if (fork()) { print "Content-type: text/html\n\n"; print "ok"; exit; } close(STDIN); close(STDOUT); close(STDERR); #start doing lots of things that are time consuming blah1(); blah2(); ...

You can add error checking to fork and direct STDERR to a log file, but you get the idea.

A better solution would provide feedback to the user. This article shows how it can be done.

Replies are listed 'Best First'.
Re^2: Trigger perl scrip remotely using http
by saberworks (Curate) on Mar 25, 2009 at 21:21 UTC
    Just to clarify, this suggestion is to do a fork on the server so the parent process (the one you call over http) starts a child and then returns content to your client script immediately. The parent will then exit while the child happily continues forever.
Re^2: Trigger perl scrip remotely using http
by rethaew (Sexton) on Mar 25, 2009 at 23:20 UTC
    Yes, works perfectly. Thank you.