Nov 142013
 

I wanted to rename a whole bunch of models to transform their names into all lowercase with just the hostname rather than the FQDN.
I used this script to do it with bash and vnmsh. The script will loop through all models found by the query with a model type handle, and then renames then with a vnmsh update command.


#!/bin/bash
export CLIMNAMEWIDTH=70
OldIFS=$IFS
IFS=$'\n'
WORKPATH="/opt/CA/Spectrum/vnmsh"

$WORKPATH/connect

## Pingable
MDLLIST=`$WORKPATH/show models mth=0x10290`
MDLLIST=`echo "$MDLLIST" | grep -vi mname`

for x in $MDLLIST; do
MDLHANDLE=`echo $x | awk -F '[ |.]+' ' { print $1 } '`
MDLNAME=`echo $x | awk -F '[ |.]+' ' { print tolower($2) }'`
echo $MDLHANDLE
echo $MDLNAME

$WORKPATH/update mh=$MDLHANDLE attr=0x1006e,val=$MDLNAME
done
$WORKPATH/disconnect
IFS=$OldIFS

Share

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.