Showing results for 
Search instead for 
Do you mean 

help in script

Highlighted
Occasional Contributor

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!
4 REPLIES
Acclaimed Contributor Acclaimed Contributor

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 Valued Contributor

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 Honored Contributor

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 Acclaimed Contributor

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