in reply to Executing a program or series of programs in perl.
I take it you'd like to send one command off to do its work while you start another one? You should look at forking a new process for each task, or using threads to divy up the processing work. For instance, here's a quick and dirty start:
use strict; use warnings; use threads; my ($thr, @threads); INPUT: print "What do you want me to do?\n"; my $work = <STDIN>; chomp $work; if ($work eq "permissions") { $thr = threads->create(sub { print `sh /root/scripts/security.sh` }) +; push(@threads, $thr); #keep track of the thread print "security.sh sent into background\n"; goto INPUT; } elsif ($work eq "apachelog") { $thr = threads->create(sub { print `perl /root/scripts/apachelog.pl` + }); push(@threads, $thr); #keep track of the thread print "apachelog.pl sent into background.\n"; goto INPUT; } elsif ($work eq "exit") { $_->join() for @threads; # cause threads to return home after finish +ing. exit 0; }
Hope that helps.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Executing a program or series of programs in perl.
by mikey (Acolyte) on May 09, 2003 at 03:52 UTC | |
by djantzen (Priest) on May 09, 2003 at 03:59 UTC | |
by mikey (Acolyte) on May 09, 2003 at 04:04 UTC | |
by mikey (Acolyte) on May 09, 2003 at 04:01 UTC |