Hacking shell scripts
Using sh and widtools to make your scripts friendly
Screen Shots
#!/bin/sh
TMP="/tmp/`whoami`"
gethost () {
host=$(widtools -input -label "Enter Hostname" -text)
}
getcomm () {
comm=$(widtools -input -label "Enter Community" -text)
}
getmibvar() {
mibvar=$(widtools -input -label "MIB Variable" -text)
}
getsubnet() {
subnet=$(widtools -input -label "Enter subnet /24)" -text)
}
item=$(widtools -menu -label "#!/bin/sh / xForms SNMP utils Script "\
"snmpwalk" \
"snmptable" \
"snmpnetstat"\
"snmpget" \
"Exit")
if [ "$item" = "1" ]; then
gethost
getcomm
getmibvar
snmpwalk -s $host $comm $mibvar > $TMP
VIEW="$TMP"
fi
if [ "$item" = "2" ]; then
gethost
getcomm
getmibvar
snmptable $host $comm $mibvar > $TMP
VIEW="$TMP"
fi
if [ "$item" = "3" ]; then
gethost
getcomm
snmpnetstat -s $host $comm > $TMP
VIEW="$TMP"
fi
if [ "$item" = "4" ]; then
gethost
getcomm
getmibvar
snmpget $host $comm $mibvar > $TMP
VIEW="$TMP"
fi
if [ "$item" = "5" ]; then
exit
fi
widtools -dialog \
-label "$VIEW" \
-showfile $VIEW \
-height 500 \
-width 650 \
if [ -f $TMP ]; then
rm $TMP
fi
./snmputilxform
|