Re: help in script (163 Views)
Reply
Occasional Contributor
Anish Kumar
Posts: 6
Registered: ‎06-24-2010
Message 1 of 5 (163 Views)

help in script

Hi Experts,

please help me on this

If i run this command
ovtopodump -lr |awk '/INTERFACE DESCRIPTION/

The o/p will be like this

INTERFACE DESCRIPTION: Loopback0
INTERFACE DESCRIPTION: Loopback1
INTERFACE DESCRIPTION: Serial0/2/0:0
INTERFACE DESCRIPTION: FastEthernet0/1


I need to automate this command
1. should be taken from a file
2. INTERFACE DESCRIPTION should be compared, if yes then command should be executed.

Cheers!
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 5 (163 Views)

Re: help in script

Hi:

To run a command with a list as you are asking could look something like:

# cat ./myrun
#!/usr/bin/sh
while read HOST
do
echo "HOST=${HOST}"
ovtopodump -lr ${HOST}|awk '/INTERFACE DESCRIPTION/'
done < ./myhosts
exit 0

...where the 'myhosts' file has lines of server hostname's, one per line.

You said:

> INTERFACE DESCRIPTION should be compared, if yes then command should be executed.

Compared to what? and what should be executed?

Regards!

...JRF...

Valued Contributor
nightwich
Posts: 259
Registered: ‎01-02-2007
Message 3 of 5 (163 Views)

Re: help in script

Hi Kumar


Script right by Fergunson should work

Another option:


for i in `/tmp/myhost`
do
ovtopodump -lr $i|awk '/INTERFACE DESCRIPTION/'
done

Regards.
Honored Contributor
Suraj K Sankari
Posts: 1,659
Registered: ‎09-09-2008
Message 4 of 5 (163 Views)

Re: help in script

Hi Nightwatch,
>>for i in `/tmp/myhost`

It should be like this you forget the "cat"

for i in `cat /tmp/myhost`
do
ovtopodump -lr $i|awk '/INTERFACE DESCRIPTION/'
done

Suraj
Acclaimed Contributor
Dennis Handly
Posts: 25,290
Registered: ‎03-06-2006
Message 5 of 5 (163 Views)

Re: help in script

>Suraj: It should be like this, you forget the cat

Or just toss the cat:
for i in $(< /tmp/myhost); do
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.