File: unix_users.pl

package info (click to toggle)
cacti 1.2.30%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,184 kB
  • sloc: php: 123,193; javascript: 29,825; sql: 2,595; xml: 1,823; sh: 1,229; perl: 194; makefile: 65; python: 51; ruby: 9
file content (19 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl

delete @ENV{qw(PATH)};
$ENV{PATH} = '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin';

my $grep_string= $ARGV[0];
($grep_string) = $grep_string =~ /^([\w]+)$/;

chomp $grep_string;

if ($grep_string eq '') {
  open(PROCESS, "who | grep -c : |");
}else{
  open(PROCESS, "who | grep : | grep -c $grep_string |");
}
$output = <PROCESS>;
close(PROCESS);
chomp($output);
print $output;