-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_group.pl
More file actions
39 lines (38 loc) · 1.28 KB
/
test_group.pl
File metadata and controls
39 lines (38 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl -w
$grp = 'Automated-NON-PROD-VADP-Reruns';
$return = remove_clients_from_group($grp);
sub remove_clients_from_group {
$val1 = ". type: NSR client\\;group:$grp'\n'show name\\;group'\n'print";
(@return) = `/usr/bin/echo $val1 | /usr/sbin/nsradmin -i - `;
$group = '';
foreach $val (@return) {
chomp $val;
$val =~ s/^\s*//; # Take off leading spaces
$val =~ s/\;//; # Take off trailing semi
next if $val =~ /Current query set/;
if ($val =~ /name:/) {
if (defined $client) {
if ($group =~ /^$grp/) {
$group =~ s/$grp, //;
} else {
$group =~ s/, $grp//;
}
$val1 = ". type: NSR client\\;name:$client'\n'update group:$group";
(@return1) = `/usr/bin/echo $val1 | /usr/sbin/nsradmin -i - `;
}
($client) = ($val =~ /name: (\S+)$/);
} elsif ($val =~ /group/) {
($val) =~ s/group: //;
$group = $val;
} else {
$group = "$group$val";
}
}
if ($group =~ /^$grp/) {
$group =~ s/$grp, //;
} else {
$group =~ s/, $grp//;
}
$val1 = ". type: NSR client\\;name:$client'\n'update group:$group";
(@return1) = `/usr/bin/echo $val1 | /usr/sbin/nsradmin -i - `;
}