⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make_table

📁 unix/linux下的路由守护程序
💻
字号:
#!/bin/sh###	$Id: make_table,v 1.3 1998/09/15 16:48:28 wfs Exp $##    MIB Table/Group Maker##	This is a file designed to create an input file for nroff,#	includable in a MIB document by putting a line of the form##	.so mibTableFile##	into the boilerplate file.  This works on the principle of#	conservation of boilerplate.##	input variables:##	$document	The document being instrumented#	$mib		The name of the nroff input file#	$group		The page heading textt="Table"e="Entry"g="Group"embedded_table=""object_type() {	case ${1} in		INTEGER| \		DisplayString| \		Gauge| \		Counter| \		PhysAddress| \		TimeTicks| \		ObjectID| \		NetworkAddress| \		IpAddress| \		OctetString)			return 1 ;			;;		*)			echo "Invalid type: " ${1} ;			return 0 ;	esac}entryname() {	echo ${1} | sed -e 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;G;s/\(.\).*\n./\1/'}##	make_table "$mib" "$entry" "$i" "$document" #if [ ${#} -eq 4 ]; then    document="$4"    mib="$1"    echo .bp >> $mib    echo -n "What is the title of the table or group for the Table of Contents? " ;    read group ;    echo -n "What is the nroff section number (6.?)? " ;    read number ;    echo \.\$0 \"$group\" \"$number\" >> $mib    echo  --\  $group >> $mib    echo '' >> $mib    fmt << EOFDescribe the group; these comments will head the ${mib} area.CONTROL D terminates input.EOF    fmt | awk '{ printf "-- %s\n", $0 ; }' >> ${mib}    echo "" ;    echo '' >> $mib    table="table"else    echo -n "What document is this? " ;    read document ;    echo -n "What is the name of the '.so' file? " ;    read mib ;    echo .bp >> $mib    echo -n "What is the title of the table or group for the Table of Contents? " ;    read group ;    echo -n "What is the nroff section number (6.?)? " ;    read number    echo \.\$0 \"$group\" \"$number\" >> $mib    echo  --\  $group >> $mib    echo '' >> $mib    fmt << EOFDescribe the group; these comments will head the ${mib} area.CONTROL D terminates input.EOF    fmt | awk '{ printf "-- %s\n", $0 ; }' >> ${mib}    echo "" ;    echo '' >> $mib    echo -n "Is this a group or a table? " ;    read tablefiecho "" ;## describe the Table#if [ "table" = "$table" ]; then##	Get description of Table#	fmt << EOFBy convention, a table or group has an identifying header thatis part of every object name inside it, like the IP Groupcontains the ipNetToMediaTable and the ipRouteTable, and theipRouteTable specifies the ipRouteEntry and in turn theipRouteNextHop.  The base name for the IP Group is 'ip', andthe base name for the ipRouteTable is 'ipRoute'.EOF    echo ''    echo -n "What is the base name? " ;    read base    table="$base$t"    entry="$base$e"    sequence=`entryname ${entry}`    echo $table OBJECT-TYPE >> $mib    echo '   ' SYNTAX ' ' SEQUENCE OF $sequence >> $mib    echo '   ' ACCESS ' ' not-accessible >> $mib    echo '   ' STATUS ' ' mandatory >> $mib    echo '   ' DESCRIPTION >> $mib    echo .fi >> $mib    echo .in +.75i >> $mib    fmt << EOFPlease describe the ${table} (without quotes).This is probably something of the form "A list of ...".CONTROL D terminates input.EOF    input=`fmt` ;    echo \"${input}\" | fmt >> ${mib}    echo ""    echo .in -.75i >> $mib    echo .nf >> $mib    echo '   ' REFERENCE >> $mib    echo .fi >> $mib    echo .in +.75i >> $mib    fmt << EOFPlease tell me what section and paragraph of ${document} isbeing instrumented by the ${table}?EOF    read input    echo \"$document "${input}"\" >> $mib    echo .in -.75i >> $mib    echo .nf >> $mib    if [ ${#} -eq 4 ]; then        echo '    ::= {' $2 $3 '}' >> $mib    else        echo -n "What is the ASN.1 description for ${table}? " ;	read input        echo '    ::= {' "${input}" '}' >> $mib    fi    echo '' >> $mib##	Describe the Entry#    echo $entry OBJECT-TYPE >> $mib    echo '   ' SYNTAX ' ' $sequence >> $mib    echo '   ' ACCESS ' ' not-accessible >> $mib    echo '   ' STATUS ' ' mandatory >> $mib    echo '   ' DESCRIPTION >> $mib    echo .fi >> $mib    echo .in +.75i >> $mib    fmt << EOFPlease describe the ${entry}, (without quotes).This is probably something of the form "A single ...".CONTROL D terminates input.EOF    input=`cat` ;    echo "" ;    echo \"${input}\" | fmt >> ${mib}    echo .in -.75i >> $mib    echo .nf >> $mib    fmt << EOFAn instance is one or more of the variables in the entry,separated by commas, telling me how to specifically get the oneI want.EOF    echo -n "How do you instantiate ${entry}? "    read input ;    echo '   ' INDEX '{' "${input}" '}' >> $mib    echo '    ::= {' $table 1 '}' >> $mib    echo '' >> $mib    echo $sequence '::=' >> $mib    echo '    SEQUENCE {' >> $mibelse##	Get description of Group#    table=""    echo -n "What is the group's base name? "    read base ;    entry="$base$g"##	Describe a Group#    echo -n "What is the ASN.1 description for ${entry}? "    read input    echo $entry OBJECT IDENTIFIER '::= {' "${input}" '}' >> $mib    echo '' >> $mibfi##	Build the SEQUENCE#echo "" ;echo -n "How many objects are there in ${entry}? "read highest ;i=1 ;objects="";while [ ${i} -le ${highest} ]; do	echo "" ;	echo -n "Name object ${i}: ${base}" ; 	read part ;	object="${base}${part}" ;	done=0	while [ ${done} -eq 0 ]; do		echo -n "What type is ${object}? " ;		read type		object_type ${type}		done=${?}	done	objects="${objects} ${object} ${type}" ;	if [ "${table}" ]; then	        echo '       ' ${object} >> $mib	        echo -n '           ' ${type} >> $mib	        if [ ${i} -eq ${highest} ]; then        		echo "" >> $mib	        else			echo "," >> ${mib}	        fi	    fi	i=`expr ${i} + 1` ;doneif [ "$table" ]; then    echo '}' >> $mib    echo '' >> $mibfi##	Build the various Object Descriptions#i=1;set ${objects}while [ ${#} -gt 0 ]; do	object=${1} ; shift	type=${1} ; shift	case ${type} in		TABLE)	    		embeded_table="${embeded_table} ${object}" ;			set -x		        make_table "${object}" "${entry}" "${i}" "${document}" 			set +x			;;					*)			make_object "${object}" "${type}" "${entry}" "${i}" "${mib}" "${document}" 	esac    i=`expr ${i} + 1` ;done##	import the embedded tables#for i in $embedded_table; do	echo .so ${i} >> $mibdone

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -