Created
August 26, 2011 14:36
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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