1752339 Members
5509 Online
108787 Solutions
New Discussion юеВ

Help in writing script.

 
SOLVED
Go to solution
Soul_1
Respected Contributor

Help in writing script.

Hi all,

i am not at all exposed to this scriting.But i tried to write one small script.
################
#this is a test snmp script
clear
read IP
/opt/OV/bin/snmpwalk -c cmstrread $IP
exit 0

###########

It worked fine.But now my requirement is to give multiple input.i.e once this is completed it should wait for the net input.

Please help regarding this.

Thanks in advance..!!
5 REPLIES 5
Solution

Re: Help in writing script.

Try this:

#!/usr/bin/sh
clear
echo "Enter IP or x to quit > \c"
while read ip
do
[ "${ip}" = "x" ] && exit 0
/opt/OV/bin/snmpwalk -c cmstrread ${ip}
echo "Enter IP or x to quit > \c"
done





HTH

Duncan

I am an HPE Employee
Accept or Kudo
Soul_1
Respected Contributor

Re: Help in writing script.

Thanks a lot..!!

It worked well.

It would be more helpful if it met another requirement.

since the o/p of this snmpwalk is too large and i have to wait for a long time .

i want to to stop this process in middle and it should ask for the next input and run the same command again.


is it possible..??
Dennis Handly
Acclaimed Contributor

Re: Help in writing script.

>I want to to stop this process in middle and it should ask for the next input

You could do:
/opt/OV/bin/snmpwalk -c cmstrread ${ip} | more

If you type "q" to more, it will quit.
OldSchool
Honored Contributor

Re: Help in writing script.

or you could do:

nohup ./yourscript > somefile &


then:

tail -f somefile

will show you all results up to the current and continue to follow the file. you could also log out and come back an examine it later if needed...
Dennis Handly
Acclaimed Contributor

Re: Help in writing script.

>OldSchool: tail -f somefile

The benefits of my more above is that when you quit, you go on to the next file. The con is that the buffer may get full and so it waits.
Or you could put it in a file and use vi to skip the next output.