I want to shell execute a script through SNMP
command.So for that script i have configured OID
in snmpd.conf
under /etc/snmp
folder.
My script looks like working is just to redirect "text"
to output.txt
file and then print script executed on console.
#!/usr/bin/ksh
Input_path="$HOME/input.txt"
Out_Path="$HOME/output.txt"
#I have to take the line_num from output.txt which is actually number of line present in output.txt
line_num=`wc -l <$out`
#after that i need to take that line from INPUT file
line=`head -$a $Input_path | tail -1 `
#i need to uppend data to 1 kb for that i am using typset command
typeset -L1024 line
#I am increasing value of a
a=`expr $a + 1`
#same i am echo in file so at this point number of line in file will increase by 1
echo $a >> $Out_Path
#this is the final output which i want .
echo -e "$line\n"
if i am using snmpwalkcommand from node ...1
snmpwalk command the output is
a
and the updated output.txt file is 1 2
snmpwalk command the output is
c
and the updated output.txt file is 1 2 3 4
snmpwalk command the output is
c
and the updated output.txt file is 1 2 3 4 5
This type of processing i am doing because data is more that 1 kb in output.txt and i am not able to fetch more than 1 kb record in snmpget command, that's why i am doing this process to get whole data.
a) try to include a "shebang" line ( #!/bin/sh
) as very first line of your script
b) try to set full path to your file, like echo "text" > /tmp/output.txt
c) be sure that path you write to is writable by UID of snmpd ( /tmp/
usually is)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.