in reply to Kill User

You may be interested in the =~ m// operation instead of grep. I'd also use $_ to simplify other stuff:
foreach (@users) { if (/$target/) { $rec = (split)[3]; if ($rec =~ /\D/) { next if $rec =~ /dtr/; ... etc
Though mainly this is just a style thing.

In addition, your outermost else block seems weird. The first test in the block is for /dtr/, which should never be true, since your outer test is for /\D/, or non-digits, which would have matched already.

When is $done set? use strict; would have alerted you that this is only used once in your code. Your script seems to be an infinite loop.

Also, a security note: if your PATH has been modified at all to cause you to run a different 'finger' than usual, or if someone is able to mangle their finger information so as to put arbitrary text on the 4th field, your `/usr/sbin/fuser -k /dev/tty$rec[3]` statement could potentially execute arbitrary code. As root, this could be a very bad thing. Consider perlsec and running with taint-checking enabled.

I don't mean for this to be a critique of your code.. I just feel you might be interested. :)

Replies are listed 'Best First'.
RE: RE: Kill User
by Octavian (Monk) on Oct 30, 2000 at 21:34 UTC
    finally someone who doesnt beat up on me ;) yes, it is meant to be an infinite loop, so if they try to log on again, it is still "hunting" them, this program was actually written very quickly during one of my "perl wars" with another sysadmin, in an attempt to get him off the system before he did something to me. I have never been to a perl class or anything of the sort, so to be honest, I have never heard of the strict command or seen it used. so that would explain why I didnt use that or used the system calls. my code should be improving now cause of this page ;)
      In that case, this site should help you immensely. Good luck.