diff options
author | elie <elie> | 2010-11-28 23:50:13 +0000 |
---|---|---|
committer | elie <elie> | 2010-11-28 23:50:13 +0000 |
commit | fd2d1b33fc40c1efcce37203147dd0a33107af48 (patch) | |
tree | 48801c199d4524ba2dd6c646ce09d352c36ef4cc | |
parent | da183f33b4191d5ceb55d5155d666cfeaed6fd96 (diff) | |
download | pysnmp-fd2d1b33fc40c1efcce37203147dd0a33107af48.tar.gz |
remove output file on convertion failure
-rw-r--r-- | tools/build-pysnmp-mib | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/build-pysnmp-mib b/tools/build-pysnmp-mib index 65c522b..9465ee1 100644 --- a/tools/build-pysnmp-mib +++ b/tools/build-pysnmp-mib @@ -10,7 +10,7 @@ smidump=smidump # part of libsmi distro while getopts o: o do case "$o" in - o) exec 5>"$OPTARG" 1>&5 || { echo >&2 "Redirection failed"; exit 1; } ;; + o) outFile=$OPTARG ;; [?]) echo >&2 "\ Convert MIB text file into PySNMP-compliant module, see http://pysnmp.sf.net. Usage: $0 [-o pysnmp-mib-file ] [ mib-text-file ]\ @@ -19,6 +19,10 @@ Usage: $0 [-o pysnmp-mib-file ] [ mib-text-file ]\ esac done +[ -n "$outFile" ] && { + exec 5>"$outFile" 1>&5 || { echo >&2 "Redirection failed"; exit 1; } +} + shift $((OPTIND-1)) [ $# -gt 1 ] && { echo >&2 "Extra arguments given"; exit 1; } @@ -45,6 +49,7 @@ egrep -q 'FROM *RFC' $mibFile 2> /dev/null && ! egrep -q 'FROM *SNMPv2-' $mibFil } $smidump -k -f python $tmpFile 2> /dev/null | $libsmi2pysnmp || { [ -f $tmpFile ] && rm -f $tmpFile; + [ -n "$outFile" ] && rm -f $outFile; echo >&2 "$smidump -k -f python $mibFile | $libsmi2pysnmp fails"; echo >&2 "make sure you are using libsmi version > 0.4.5 (or svn)"; exit @@ -52,6 +57,7 @@ egrep -q 'FROM *RFC' $mibFile 2> /dev/null && ! egrep -q 'FROM *SNMPv2-' $mibFil rm -f $tmpFile } || { $smidump -k -f python $mibFile 2> /dev/null | $libsmi2pysnmp || { + [ -n "$outFile" ] && rm -f $outFile; echo >&2 "$smidump -k -f python $mibFile | $libsmi2pysnmp fails"; echo >&2 "make sure you are using libsmi version > 0.4.5 (or svn)"; exit |