-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget-printer-model.sh
More file actions
executable file
·40 lines (35 loc) · 1.03 KB
/
Copy pathget-printer-model.sh
File metadata and controls
executable file
·40 lines (35 loc) · 1.03 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
#!/bin/sh
# get-printer-model.sh -- query a printer over the network via SNMP for its model
# author: Sean Ellefson
# email: scellef@pdx.edu
# date: 10/22/2014
# SNMP MIB declarations
model='1.3.6.1.2.1.25.3.2.1.3.1'
pagecount='1.3.6.1.2.1.43.10.2.1.4.1.1'
printcount () {
printer_model=`snmpget -v1 -Ovq -c public $line $model 2> /dev/null`
printer_count=`snmpget -v1 -Ovq -c public $line $pagecount 2> /dev/null`
}
if [ "$*" = "-h" ] ; then
cat << EOF
get-printer-model.sh -- query a printer over the network via SNMP for its model.\n"
usage: get-printer-model.sh [network_address]
get-printer-model.sh -h
EOF
exit 0
elif [ "$1" != "" ] ; then
line=$1
printcount
else
printf "Enter the printer's address: "
read line
printcount
fi
if [ -z printer_model ] ; then
printf "Unable to contact to contact printer. Please confirm network address and try again.\n"
exit 1
else
printf "Printer at $line reports itself as: $printer_model\n"
printf "Number of pages reported as printed: $printer_count\n"
exit 0
fi