Skip to content
Snippets Groups Projects
Commit c104e56f authored by Martin Mareš's avatar Martin Mareš
Browse files

Scan: Implemented --exit

parent bb972f53
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ use Digest::SHA;
my $verbose = 0;
my $close = 0;
my $opt_exit = 0;
my $s_all = 0;
my $s_encodings = 0;
my $s_iodev = 0;
......@@ -44,6 +45,7 @@ GetOptions(
"psversion!" => \$s_psversion,
"verbose!" => \$verbose,
"close!" => \$close,
"exit!" => \$opt_exit,
) and @ARGV == 1 or die <<AMEN ;
Usage: $0 [<options>] <hostname>
......@@ -59,6 +61,7 @@ Options:
--psversion Scan PS interpreter version
--verbose Be verbose and dump all communication with the printer
--close Close connection after each scan to flush buffers
--exit Send Universal Exit Language after each scan to flush buffers
AMEN
my ($host) = @ARGV;
......@@ -236,10 +239,16 @@ sub need_ps() {
enter_ps();
}
sub end_ps() {
tx("flush\n");
uel() if $opt_exit;
}
sub scan_psversion() {
heading("PS interpreter version");
need_ps();
tx("version == revision == (%END%) = flush\n");
tx("version == revision == (%END%) =\n");
end_ps();
my $ver = rx_until("%END%");
print join(" ", @$ver), "\n";
}
......@@ -247,7 +256,8 @@ sub scan_psversion() {
sub scan_pagedev() {
heading("PS page device parameters");
need_ps();
tx("currentpagedevice showdict (%END%) = flush\n");
tx("currentpagedevice showdict (%END%) =\n");
end_ps();
my $dict = rx_until("%END");
out_dict($dict);
}
......@@ -262,8 +272,9 @@ sub scan_iodev() {
currentdevparams showdict
} 100 string /IODevice resourceforall
(%>>%) =
(%END%) = flush
(%END%) =
AMEN
end_ps();
out_dict(rx_until("%END"));
}
......@@ -277,8 +288,9 @@ sub scan_outdev() {
cvn /OutputDevice findresource showdict
} 100 string /OutputDevice resourceforall
(%>>%) =
(%END%) = flush
(%END%) =
AMEN
end_ps();
my $odev = rx_until("%END%");
out_dict($odev);
}
......@@ -328,8 +340,9 @@ sub scan_psfonts() {
(%>>%) = flush % Flush to avoid buffer management bugs on Xerox Phaser 3300
} 100 string /Font resourceforall
(%>>%) =
(%END%) = flush
(%END%) =
AMEN
end_ps();
my $fonts = parse_dict(rx_until("%END%"));
if ($verbose) {
show_dict($fonts);
......@@ -367,8 +380,9 @@ sub scan_encodings() {
/Encoding findresource ==
} 100 string /Encoding resourceforall
(%>>%) =
(%END%) = flush
(%END%) =
AMEN
end_ps();
my $encs = parse_dict(rx_until("%END%"));
for my $e (keys %$encs) {
my $array = $encs->{$e};
......
......@@ -10,7 +10,7 @@ my $host = $ARGV[0] or die "Usage: $0 <host>\n";
print "Scanning $host...\n";
my $sess = Net::SNMP->session(
-hostname => $host . '.kam.hide.ms.mff.cuni.cz',
-hostname => $host . '.kam.mff.cuni.cz',
-version => 1,
-community => 'public',
) or die;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment