Skip to content

Instantly share code, notes, and snippets.

@sr75
Created August 26, 2011 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sr75/1173535 to your computer and use it in GitHub Desktop.
Save sr75/1173535 to your computer and use it in GitHub Desktop.
httpi fork perl process for shell script (.pl,.ksh) file name passed through url
#!/bin/perl
($var_name, $process_name) = split(/=/,$ENV{'QUERY_STRING'});
print "HTTP/1.0 200 OK\r\n";
print "Content-type: text/plain\r\n\r\n";
print "OK";
#print $ENV{'QUERY_STRING'};
$process_path = "";
my $pid = fork;
die "Forking shell process failed: $!" unless defined $pid;
unless ($pid) {
close(STDOUT);
close(STDERR);
close(STDIN);
exec("nohup $process_path$process_name");
exit(0);
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment