Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=6022956
By: stevenworr
I'm not exactly sure what you're trying to do, but I made the script a bit bashier
than it was before...
* Double quotes without interpolation become single quotes.
* Use set to parse.
* Use default variable assignments.
* Use $() instead of ``
* Use -z instead of ""
* etc...
:-)
#!/bin/bash
# 20080107 v0.2 - LnxGnome
[[ -z "$1" ]] && { echo 'error: required parameter, internal IP or hostname
of router, is missing!' 1>&2 ; exit 99; }
GW="$1"
CM="${2:=public}"
if ! EXTIF=$(snmpwalk -Ov -Oq -c $CM -v 1 $GW ipRouteIfIndex.0.0.0.0 2>/dev/null
then
echo 'error: can not access router!' 1>&2
exit 1
elif [[ "$EXTIF" == 'End of MIB' ]]
then
echo 'warning: Default gateway not found. Check community name and routing
table in router!' 1>&2
exit 2
fi
set -- $(snmpwalk -Os -Oq -c $CM -v 1 $GW ipAdEntIfIndex)
[[ $2 ~= "$EXTIF" ]] && ENTRY="$1"
IP=${ENTRY/ipAdEntIfIndex./}
echo $IP
______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=399427
|