{
    "mode": "man",
    "parameter": "MIB2C.CONF",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/MIB2C.CONF/5/json",
    "generated": "2026-06-15T16:00:32Z",
    "synopsis": "% cat > mib2c.test.conf  << EOF @foreach $t table@\nStarting table $t\n@foreach $c column@\necho $t has column $c which has a syntax of $c.syntax\n@end@\n@end@ EOF\n% mib2c -c mib2c.test.conf internet",
    "sections": {
        "NAME": {
            "content": "mib2c.conf - How to write mib2c.conf files to do ANYTHING based on MIB input.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "% cat > mib2c.test.conf  << EOF @foreach $t table@\nStarting table $t\n@foreach $c column@\necho $t has column $c which has a syntax of $c.syntax\n@end@\n\n@end@ EOF\n\n% mib2c -c mib2c.test.conf internet\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  mib2c.conf  script  language is a MIB-particular language designed to easily process MIB\nnodes in ways that you want.  mib2c is a misnomer (for historical purposes), because you  can\nproduce  anything  (not  just C code).  Look in the Net-SNMP \"local\" directory for a bunch of\nexample mib2c.*.conf files and behold the power before you.\n",
            "subsections": []
        },
        "COMMANDS": {
            "content": "All commands within mib2c.conf files are embraced by @ signs.  Anything with an @ sign at the\nfront  and  back of the line is generally supposed to be a mib2c specific command.  These are\ndetailed here:\n\n@open FILE@\nwrites generated output to FILE note that for file specifications,  opening  '-'  will\nprint to stdout.\n\n@append FILE@\nappends the given FILE\n\n@close FILE@\ncloses the given FILE\n\n@push@ save  the current outputs, then clear outputs. Use with @open@ and @pop@ to write to a\nnew file without interfering with current outputs.\n\n@pop@  pop up the process() stack one level. Use after a @push@ to return to the previous set\nof open files.\n\n@foreach $VAR scalar@\nrepeat iterate over code until @end@ setting $VAR to all known scalars\n\n@foreach $VAR table@\nrepeat iterate over code until @end@ setting $VAR to all known tables\n\n@foreach $VAR column@\nrepeat  iterate over code until @end@ setting $VAR to all known columns within a given\ntable.  Obviously this must be called within a foreach-table clause.\n\n@foreach $VAR nonindex@\nrepeat iterate over code until @end@ setting  $VAR  to  all  known  non-index  columns\nwithin a given table.  Obviously this must be called within a foreach-table clause.\n\n@foreach $VAR internalindex@\nrepeat  iterate over code until @end@ setting $VAR to all known internal index columns\nwithin a given table.  Obviously this must be called within a foreach-table clause.\n\n@foreach $VAR externalindex@\nrepeat iterate over code until @end@ setting $VAR to all known external index  columns\nwithin a given table.  Obviously this must be called within a foreach-table clause.\n\n@foreach $VAR index@\nrepeat  iterate over code until @end@ setting $VAR to all known indexes within a given\ntable.  Obviously this must be called within a foreach-table clause.\n\n@foreach $VAR notifications@\nrepeat iterate over code until @end@ setting $VAR to all known notifications\n\n@foreach $VAR varbinds@\nrepeat iterate over code until @end@ setting $VAR to all known varbinds Obviously this\nmust be called within a foreach-notifications clause.\n\n@foreach $LABEL, $VALUE enum@\nrepeat iterate over code until @end@ setting $LABEL and $VALUE to the label and values\nfrom the enum list.\n\n@foreach $RANGESTART, $RANGEEND range NODE@\nrepeat iterate over code until @end@ setting $RANGESTART and $RANGEEND to the  legal\naccepted range set for a given mib NODE.\n\n@foreach $var stuff a b c d@\nrepeat  iterate  over  values  a,  b, c, d as assigned generically (ie, the values are\ntaken straight from the list with no mib-expansion, etc).\n\n@while expression@\nrepeat iterate over code until the expression is false\n\n@eval $VAR = expression@\nevaluates expression and assigns the results to $VAR.  This is not a full  perl  eval,\nbut  sort  of  a  \"\"psuedo\"\" eval useful for simple expressions while keeping the same\nvariable name space.  See below for a full-blown export to perl.\n\n@perleval STUFF@\nevaluates STUFF directly in perl.  Note that all mib2c variables  interpereted  within\n.conf  files  are  in $vars{NAME} and that a warning will be printed if STUFF does not\nreturn 0. (adding a 'return 0;' at the end of STUFF is a workaround.\n\n@startperl@\n\n@endperl@\ntreats everything between these tags as perl code, and evaluates it.\n\n@next@ restart foreach; should only be used inside a conditional.  skips out of current  con‐\nditional, then continues to skip to end for the current foreach clause.\n\n@if expression@\nevaluates  expression, and if expression is true processes contained part until appro‐\npriate @end@ is reached.  If the expression is false, the next @elsif expression@  ex‐\npression (if it exists) will be evaluated, until an expression is true. If no such ex‐\npression exists and an @else@ clause is found, it will be evaluated.\n\n@ifconf file@\nIf the specified file can be found in the conf file search path,  and  if  found  pro‐\ncesses  contained  part until an appropriate @end@ is found. As with a regular @if ex‐\npression@, @elsif expression@ and @else@ can be used.\n\n@ifdir dir@\nIf the specified directory exists, process contained part until an  appropriate  @end@\nis  found.  As  with  a  regular @if expression@, @elsif expression@ and @else@ can be\nused.\n\n@define NAME@\n\n@enddefine@\nMemorizes \"\"stuff\"\" between the define and enddefine tags for later calling as NAME by\n@calldefine NAME@.\n\n@calldefine NAME@\nExecutes stuff previously memorized as NAME.\n\n@printf \"expression\" stuff1, stuff2, ...@\nLike all the other printf's you know and love.\n\n@run FILE@\nSources  the  contents  of  FILE  as  a  mib2c file, but does not affect current files\nopened.\n\n@include FILE@\nSources the contents of FILE as a mib2c file and appends its  output  to  the  current\noutput.\n\n@prompt $var QUESTION@\nPresents the user with QUESTION, expects a response and puts it in $var\n\n@print STUFF@\nPrints stuff directly to the users screen (ie, not to where normal mib2c output goes)\n\n@quit@ Bail out (silently)\n\n@exit@ Bail out!\n",
            "subsections": []
        },
        "VARIABLES": {
            "content": "Variables  in the mib2c language look very similar to perl variables, in that they start with\na \"$\".  They can be used for anything you want, but most  typically  they'll  hold  mib  node\nnames being processed by @foreach ...@ clauses.\n\nThey  also  have a special properties when they are a mib node, such that adding special suf‐\nfixes to them will allow them to be interpreted in some fashion.  The easiest way  to  under‐\nstand  this is through an example.  If the variable 'x' contained the word 'ifType' then some\nmagical things happen.  In mib2c output, anytime $x is seen it  is  replaced  with  \"ifType\".\nAdditional suffixes can be used to get other aspects of that mib node though.  If $x.objectID\nis seen, it'll be replaced by the OID for  ifType:  \".1.3.6.1.2.1.2.2.1.3\".   Other  suffixes\nthat can appear after a dot are listed below.\n\nOne  last  thing: you can use things like $vartext immediately ending in some other text, you\ncan use {}s to get proper expansion of only part of the mib2c input.  IE, $xtext will produce\n\"$xtext\", but ${x}text will produce \"ifTypetext\" instead.\n\n$var.uc\nall upper case version of $var\n\n$var.objectID\ndotted, fully-qualified, and numeric OID\n\n$var.commaoid\ncomma separated numeric OID for array initialization\n\n$var.oidlength\nlength of the oid\n\n$var.subid\nlast number component of oid\n\n$var.module\nMIB name that the object comes from\n\n$var.parent\ncontains the label of the parent node of $var.\n\n$var.isscalar\nreturns 1 if var contains the name of a scalar\n\n$var.iscolumn\nreturns 1 if var contains the name of a column\n\n$var.children\nreturns 1 if var has children\n\n$var.perltype\nnode's perl SYNTAX ($SNMP::MIB{node}{'syntax'})\n\n$var.type\nnode's ASNXXX type (Net-SNMP specific #define)\n\n$var.decl\nC data type (char, ulong, ...)\n\n$var.readable\n1 if an object is readable, 0 if not\n\n$var.settable\n1 if an object is writable, 0 if not\n\n$var.creatable\n1 if a column object can be created as part of a new row, 0 if not\n\n$var.noaccess\n1 if not-accessible, 0 if not\n\n$var.accessible\n1 if accessible, 0 if not\n\n$var.storagetype\n1 if an object is a StorageType object, 0 if not\n\n$var.rowstatus\n1  if an object is a RowStatus object, 0 if not 'settable', 'creatable', 'lastchange',\n'storagetype' and 'rowstatus' can also  be  used  with  table  variables  to  indicate\nwhether  it  contains writable, creatable, LastChange, StorageType or RowStatus column\nobjects\n\n$var.hasdefval\nreturns 1 if var has a DEFVAL clause\n\n$var.defval\nnode's DEFVAL\n\n$var.hashint\nreturns 1 if var has a HINT clause\n\n$var.hint\nnode's HINT\n\n$var.ranges\nreturns 1 if var has a value range defined\n\n$var.enums\nreturns 1 if var has enums defined for it.\n\n$var.access\nnode's access type\n\n$var.status\nnode's status\n\n$var.syntax\nnode's syntax\n\n$var.reference\nnode's reference\n\n$var.description\nnode's description\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "mib2c(1)\n\n\n\nVVERSIONINFO                                 28 Apr 2004                               MIB2C.CONF(5)",
            "subsections": []
        }
    },
    "summary": "mib2c.conf - How to write mib2c.conf files to do ANYTHING based on MIB input.",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "mib2c",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/mib2c/1/json"
        }
    ]
}