read commands from STDIN if used as pipe
[dell-switch] / sw-snmpbulkwalk.sh
index 2520233..7d27c63 100755 (executable)
@@ -3,7 +3,10 @@
 # Usage: $0 [sw [oid]]
 
 dir=/dev/shm/snmpbulkwalk/
-test ! -d $dir && mkdir $dir
+if [ ! -d $dir ] ; then
+       mkdir $dir
+       ln -sv `pwd`/snmpbulkwalk/.git $dir/
+fi
 
 . ./snmp.conf
 
@@ -14,5 +17,5 @@ if [ ! -z "$2" ] ; then
 fi
 
 ( test ! -z "$1" && echo $1 || ./sw-names ) | xargs -i sh -c \
-"snmpbulkwalk -OX -v2c -Cc -c $COMMUNITY {} $2 | tee $dir/$ext{} && cd $dir && git add $dir/$ext{} && git commit -m $2 $dir/$ext{}" #| parallel 
+"snmpbulkwalk -OX -v2c -Cc -c $COMMUNITY {} $2 | tee $dir/$ext{} && test -z "$ext" && cd $dir && git add $dir/$ext{} && git commit -m {} $dir/$ext{}" #| parallel