[Veritas-bu] Parsing the output of bpdbjobs -- Bourne shell solution!
2001-06-29 16:48:55
Subject: |
[Veritas-bu] Parsing the output of bpdbjobs -- Bourne shell solution! |
From: |
rlh AT lsil DOT com (Richard Hellier) |
Date: |
Fri, 29 Jun 2001 21:48:55 +0100 |
This is a multi-part message in MIME format.
--------------E1BF3B11EF216DED0A73725A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Attached is a Bourne shell script that shows one way to handle the
multiple fields
problem with the output from bpdbjobs. The trick is to turn the data
you have into the
"command-line" arguments to sh; then you can pick the items off one by
one using $1, $2 etc.
Less straightforward than Perl but if you're on a sh-only system ...
Cheers,
Richard.
--------------E1BF3B11EF216DED0A73725A
Content-Type: application/x-shar;
name="parse_bpdbjobs.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="parse_bpdbjobs.sh"
#! /bin/sh
###############################
#
# This script parses the
# output from bpdbjobs
# and emits a very cut-down
# version of same data ...
#
# Warning: I'm not certain
# I'm picking out the media_server
# or master_server (since they are
# the same in my setup!) -- It's
# simple to change if the wrong
# field is being plucked out ...
#
# Richard Hellier <rlh AT lsil DOT com>
#
###############################
PATH=/bin:/usr/openv/netbackup/bin/admincmd
IFS="
"
bpdbjobs -report -all_columns | \
cut -d, -f 5-8,33- | \
while read line
do {
OLDIFS="${IFS}" IFS=","
set -- ${line}
if [ $# -ge 5 ]
then {
class=$1; shift
schedule=$1; shift
client=$1; shift
media_server=$1; shift
args=
while [ "$*" ]
do {
case "$1" in
*write?time:*) write_time=`expr ${1} :
'^.*write time: \(.*\)'`
echo $class $schedule $client
$media_server $write_time
;;
esac
shift
} done
} fi
IFS=$OLDIFS
} done
--------------E1BF3B11EF216DED0A73725A--
|
|
|