-
Notifications
You must be signed in to change notification settings - Fork 0
/
racf.pl
70 lines (59 loc) · 1.3 KB
/
racf.pl
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl -w
use strict;
use feature "switch";
my @argv = @ARGV; #keep hands off the argument array
my ($printer_ip,$printer_name,$set_mandat)=@argv;
sub help{
print ("usage racf: racf PRINTER_IP PRINTER_NAME\n\n");
print ("Example: racf 192.168.11.150 HPLaserJet1120\n\nOutput:\t192.168.11.150HPLaserJet1120\n\tSYSPROG\n");
}
sub get_mandat{
my $m=int (rand(5));
my $mandat;
given ($m){
when (1) {
$mandat = "SYSPROG";
}
when (2) {
$mandat = "TOPSECRET";
}
when (3) {
$mandat = "SECRET";
}
when (4) {
$mandat = "CONFIDENT";
}
when (5) {
$mandat = "PUBLIC";
}
default {
$mandat = "PUBLIC";
}
}
return $mandat;
}
# ARG CHECKING
# If no arguments, device discovery mode
if (!$argv[0]){
help();
exit 1;
}
# If too many arguments, send error
if (scalar(@argv) >3 ){
print "To many arguments\n";
help();
exit 1;
}
unless ($set_mandat){
print "$printer_ip$printer_name\n",get_mandat();
}else{
print "$printer_ip$printer_name\n$set_mandat";
}
=head1 AUTHOR
For all intents and purposes, blame:
Paul Mosentsev C<< <p.slant@gmail.com> >>
=head1 COPYRIGHT AND LICENSE
Copyright 2009 Paul Mosentsev
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut