Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

a tool script for kicked out users quickly.

  • Loading branch information...
commit bbf39e7ba0562b24c4a796329bdf4f357f8af540 1 parent fb26c09
@soarpenguin authored
Showing with 53 additions and 0 deletions.
  1. +53 −0 kickOut.pl
View
53 kickOut.pl
@@ -0,0 +1,53 @@
+#!/bin/env perl
+
+# kickOut.pl -- a tool script for kicked out the users. {{{1
+# use the cmd "w" and "who am i" get user info.
+# use the cmd "pkill -KILL -t user" kicked out user.
+#
+# Author: soarpenguin <soarpenguin@gmail.com>
+# First release Dec.8 2013
+# 1}}}
+
+use Term::ANSIColor;
+
+my $DEBUG = 0;
+if ($DEBUG) {
+ eval q{
+ use Smart::Comments;
+ };
+ die $@ if $@;
+}
+
+# get the current user.
+my $me = `who am i`;
+(undef, $me) = split(/\s+/, $me);
+### $me
+
+# get all users current logged.
+my @other=`w`;
+my $user;
+
+print color("blue"), "Kicked out all users?\n", color("reset");
+print "Input(yes/no):";
+my $answer = <STDIN>;
+if ($answer !~ /y|Y|YES|yes/) {
+ exit 0;
+}
+
+for(my $i = 2; $i < @other; $i++) {
+ (undef, $user) = split(/\s+/, $other[$i]);
+ if ($user !~ /pts/) {
+ ### $user
+ next;
+ } elsif ($user =~ /$me/) {
+ ### $user
+ next;
+ } else {
+ ### $user
+ `pkill -KILL -t $user`;
+ if ($? != 0) {
+ print "Kill the $user failed.\n";
+ }
+ }
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.