deyaneria has asked for the wisdom of the Perl Monks concerning the following question:
Hello Lovely Monks, I have snippet of code I created to kill user processes. We were to put the processes of a specified user into an array and kill them off one by one. I have the script working with no errors and it is killing off the processes. However I'm getting a system return that is kicking me out of my do-while loop. Not sure why this is happening. Some guidance would be appreciated. This subroutine takes place after I find the user's processes and have already written them to the array and printed the array.
sub kill_process{ do { print"Kill processes for the user (y orn?\n"; my $ans = <>; chomp $ans; print "choose pid: "\n; my $pid =<>; chomp $pid; system `kill $pid`; print "process killed \n"; }while ($ans eq "Y" || $ans eq "y"); },
forgot to show the sytem return message IPC::System::Simple::run called with no arguments at testarray_perl line 52. Line 52 is the system kill line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Killing processes
by Athanasius (Archbishop) on Mar 20, 2015 at 16:04 UTC | |
by deyaneria (Acolyte) on Mar 20, 2015 at 16:17 UTC | |
by Athanasius (Archbishop) on Mar 20, 2015 at 16:55 UTC | |
by deyaneria (Acolyte) on Mar 20, 2015 at 17:19 UTC | |
|
Re: Killing processes
by choroba (Cardinal) on Mar 20, 2015 at 16:11 UTC | |
by deyaneria (Acolyte) on Mar 20, 2015 at 16:19 UTC | |
by karlgoethebier (Abbot) on Mar 20, 2015 at 18:49 UTC | |
|
Re: Killing processes
by jimw54321 (Acolyte) on Mar 20, 2015 at 18:19 UTC | |
by deyaneria (Acolyte) on Mar 20, 2015 at 18:30 UTC |