Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SCRIPT NSRADMIN

Status
Not open for further replies.

peppe71

Technical User
Feb 6, 2002
27
0
0
IT
Can you help me to write a script to report in tabular mode client,name, backup command,storage nodes, remote access?
 
Sorry, i need help for a unix script.
Thanks in advance
 
Actually, nsradmin can do almost everything you want ...

1. Generate a file (report_in) with these lines:
. NSR client
show name; backup command; storage nodes; remote access
print
q

2. Issue the following command "nsradmin -i report_in > report_out".

The report will look like this:
Current query set
name: client_a;
remote access: ;
backup command: ;
storage nodes: nsrserverhost;

name: client_b;
remote access: savepnpc;
backup command: ;
storage nodes: nsrserverhost;
...
name: client_x;
remote access: ;
backup command: ;
storage nodes: nsrserverhost;

Unfortunately, the result is not in tabular mode but at least you can import it in a spreadsheet (You may want to delete the headline first). That's obviously what you want.
 
thanks, but i want the results in tabular mode with nsradmin
 
Unfortunately, nsradmin can not deliver this by itself. Please write your own filter to convert the result.
 
can you help me a script that converts the result?
I'm write this script, but when in the backup command there is a dot dont work:

nsradmin -i reportcc|grep nsrnmo|sed -e 's/backup command: //g'|sed -e 's/ //g'|sed -e 's/;//g'>>/tmp/listansrnmo
for t in `cat /tmp/listansrnmo`
do
echo 'show name; save set; backup command'>/tmp/comandoquery
echo ' p type:NSR client; backup command:' $t>>/tmp/comandoquery
nsradmin -i /tmp/comandoquery >>/tmp/outputquery
echo >> /tmp/outputquery
done
cat /tmp/outputquery |sed -e 's/name://g'|sed -e 's/save set://g'|sed -e 's/backup command://g'|grep ';'>>/tmp/listafinal
split -l 3 /tmp/listafinal
:>/gestione/lista.out
for i in x?? ; do cat $i | xargs echo >> /gestione/Lista.out; done
rm /gestione/x??
 
Here's a low-level script. Wrap some queries around it for what you want and how you want it to look.

It isn't necessarily the cleanest, I'm sure some of the other guys here could collapse the multiple sed calls, and others would avoid the use of a temp file, but it gets the job done.

Code:
#!/bin/ksh

TMPFILE=/tmp/$$
rm ${TMPFILE} 2>/dev/null

NSRTYPE="${1}"
NSRNAME="${2}"
FIELD="${3}"

echo "option Dynamic: On" >> ${TMPFILE}
echo "option Hidden: On" >> ${TMPFILE}

echo ". type: NSR ${1}; name: ${2}" >> ${TMPFILE}
echo "show ${3}" >> ${TMPFILE}
echo "print" >> ${TMPFILE}

nsradmin -i ${TMPFILE} | tail -1 | sed s/"${3}: "/""/g | sed s/"^ *"/""/g | sed s/";$"/""/g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top