I am facing issue with running a script through snmpwalk command which should redirect a random number into a output file:
I have configured OID for script in snmpd.conf undet /etc/snmp/ as exec .1.3.6.1.4.1.99.1.53.1006 script.sh.sh /root/my_folder/script.sh
My script is as :
#!/usr/bin/ksh
Out_Path="$HOME/output.txt"
echo $RANDOM >> $Out_Path
--------------------------
Now i am executing snmpwalk command as : snmpwalk -t 10 -v 1 -c public 127.0.0.1.1.3.6.1.4.1.99.1.53.1006 and in output file i am getting 2 random number instead of 1. I am expecting only one Random number should be present in output.txt file. Can any one explain the behavior or some solution ?
Actual Problem :
I am explaining what i want to achieve.I need to execute a script through snmpget command.
Problem 1: When i use SNMPGET command then script executes and the response (internally) i am getting full (more than 1 KB) but after saving this response in a file i am doing echo $line in a while loop which will take the line of a file and as pes my expectation it should show me the whole data.(But i am able to fetch only 1 KB data )
Problem 2: To solve problem 1 i adopt a new design which is like from 1 OID(script) i got whole data in a file.After that i am executing a new script using new OID which will fetch 1 Record(1KB) and modify the existing data and update the data.So like this i will execute second script multiple time using snmpwalk with different OID so i will get all the record.But my problem is when i am trying to update the reord(file) then in one exection it is removing 2 KB data,because of this reason i posted the question.(2 times random number in 1 snmpwalk command).
I hope you understand the problem now but if you want some more details i will explain you.