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.


In reply to Killing processes by deyaneria

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.