From: Eric Bollengier Date: Mon, 22 Mar 2010 13:50:04 +0000 (+0100) Subject: Propose shell replacement to perl code, fix #1516 X-Git-Tag: Release-5.2.1~1579 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=58409c0d570210b5b18746cf3fa163d4e62d4ffe;p=bacula%2Fbacula Propose shell replacement to perl code, fix #1516 --- diff --git a/bacula/scripts/mtx-changer.in b/bacula/scripts/mtx-changer.in index 5aa9926747..ca5c5481ff 100644 --- a/bacula/scripts/mtx-changer.in +++ b/bacula/scripts/mtx-changer.in @@ -215,7 +215,7 @@ case $cmd in fi ${MTX} -f $ctl status >${TMPFILE} rtn=$? - # can be converted to awk+sed+cut, contributions are welcome + # can be converted to awk+sed+cut, see below perl -ne ' /Data Transfer Element (\d+):Empty/ && print "D:$1:E\n"; /Data Transfer Element (\d+):Full \(Storage Element (\d+) Loaded\)(:VolumeTag =\s*(.+))?/ && print "D:$1:F:$2:$4\n"; @@ -223,6 +223,11 @@ case $cmd in /Storage Element (\d+):Full( :VolumeTag=(.+))?/ && print "S:$1:F:$3\n"; /Storage Element (\d+) IMPORT.EXPORT:Empty/ && print "I:$1:E\n"; /Storage Element (\d+) IMPORT.EXPORT:Full( :VolumeTag=(.+))?/ && print "I:$1:F:$3\n";' ${TMPFILE} + # If perl isn't installed, you can use by those commands +#cat ${TMPFILE} | grep "Data Transfer Element" | awk "{print \"D:\"\$4 \$7 \$9 \$10}" | sed "s/=/:/" | sed "s/Full/F:/" | sed "s/Empty/E/" +#cat ${TMPFILE} | grep -v "Data Transfer Element" | grep "Storage Element" | grep -v "IMPORT/EXPORT" | awk "{print \"S:\"\$3 \$4 \$5}" | sed "s/IMPORT\/EXPORT//" | sed "s/Full *:VolumeTag=/F:/" | sed "s/Empty/E/" +#cat ${TMPFILE} | grep -v "Data Transfer Element" | grep "Storage Element" | grep "IMPORT/EXPORT" | awk "{print \"I:\"\$3 \$4 \$5}" | sed "s/IMPORT\/EXPORT//" | sed "s/Full *:VolumeTag=/F:/" | sed "s/Empty/E/" + rm -f ${TMPFILE} >/dev/null 2>&1 exit $rtn ;;