我想通过SNMP command.So执行一个脚本,这个脚本是我在snmpd.conf中在/etc/snmp文件夹下配置的。
我的脚本看起来只是将"text"重定向到output.txt文件,然后打印在控制台上执行的脚本。
#!/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"输出
如果我使用的是节点...1中的snmpwalkcommand命令
snmpwalk命令的输出是
一个
更新后的output.txt文件为12。
snmpwalk命令的输出是
C
更新后的output.txt文件为1 2 3 4
snmpwalk命令的输出是
C
更新后的output.txt文件为1 2 3 4 5
也就是说我得到了一个,c,e.但我需要a,b,c,d,e
这种类型的处理是因为output.txt中的数据大于1kb,而且我不能在snmpget命令中获取超过1kb的记录,这就是为什么我要做这个过程来获取整个数据。
发布于 2012-12-12 05:30:39
( a)尝试将"shebang“行(#!/bin/sh)作为脚本的第一行
( b)尝试设置文件的完整路径,如echo "text" > /tmp/output.txt
c)确保写入的路径由snmpd的UID可写(/tmp/通常是)
https://stackoverflow.com/questions/13833078
复制相似问题