[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.2.11 Built-in Primitives

Radtest built-in: getopt optstring [opt [arg [ind]]]
Getopt is used to break up command line options for subsequent parsing.

The only mandatory argument, optstring is a list of short (one-character) options to be recognized. Each short option character in optstring may be followed by one colon to indicate it has a required argument, and by two colons to indicate it has an optional argument. <FIXME> Document starting `+' and `-' chars. </>

Each subsequent invocation of getopt processes next command line argument. Getopt returns true if the argument is an option and returns false otherwise. It stores the retrieved option (always with a leading dash) in the variable opt (OPTVAR by default). If the option has an argument, the latter is stored in the variable arg (OPTARG by default). Index of the next command line argument to be processed is preserved in the variable ind (OPTIND by default).

The usual way of processing command line options is by invoking getopt in a condition expression of while loop and analyzing its return values within the loop. For example:

 
while getopt "hf:"
case $OPTVAR in
"-h")  print "Got -h option\n"
"-f")  print "Got -f option. Argument is " $OPTARG "\n"
".*")  begin
          print "Unknown option: " $OPTVAR "\n"
          exit 1
       end
  end
end

Radtest statement: input [expr name]
Evaluates expr and prints its result on standard output. Then reads a line from standard input and assigns it to the variable name.

If expr is given, name must also be present.

If name is not given, variable INPUT is used by default.

Radtest statement: set options
Sets radtest command line options. Options should be a valid radtest command line (see section 13.2.1 Invoking radtest).

Radtest statement: shift [expr]
Shift positional parameters left by one, so that $2 becomes $1, $3 becomes $2 etc. $# is decremented. $0 is not affected.

If expr is given, it is evaluated, converted to integer and used as shift value. Thus shift 2 shifts all positional parameters left by 2.

Radtest statement: return [expr]
Returns from the current function (see section 13.2.7 Function Definitions). If expr is present, it is evaluated and the value thus obtained becomes the function return value.

It is an error to use return outside of a function definition.

Radtest statement: break [n]
Exit from within a loop.If n is specified, break from number levels. n must be >= 1. If n is greater than the number of enclosing loops, an error message is issued.

See section 13.2.10 Loops, for the detailed discussion of the subject.

Radtest statement: continue [n]
Resume the next iteration of the enclosing loop. If n is specified, resume at the nth enclosing loop. n must be >= 1. If n is greater than the number of enclosing loops, an error message is issued.

See section 13.2.10 Loops, for the detailed discussion of the subject.

Radtest statement: exit [expr]
Exit to the shell. If expr is specified, it is evaluated and used as exit code. Otherwise, 0 is returned to the shell.

Radtest statement: print expr-list
Evaluate and print expressions. Expr-list is whitespace or comma-separated list of expressions. Each expression is evaluated in turn and printed to the standard output.

Radtest statement: send [flags] port-type code expr-or-pair-list
Send a request to the RADIUS server and wait for the reply. Stores reply code in the variable REPLY_CODE and reply A/V pairs in the variable REPLY (see section 13.2.8 Interacting with Radius Servers).

flags are a whitespace-separated list of variable assignments. Following variables are understood:

repeat=n
Unconditionally resend the request n times.

id=n
Specify the request ID.

keepauth=1
Do not alter request authenticator when resending the request.

port-type
Specifies which port to use when sending the request. Use `auth' to send the request to the authentication port (see section auth-port), and `acct' to send it to the accounting port (see section acct-port).

code
RADIUS request code. Either numeric or symbolic (see section 13.2.2.1 Numeric Values).

expr-or-pair-list
Specifies the A/V pairs to include in the request. This argument is either an expression evaluating to avlist, or an immediate avlist (see section 13.2.2.3 Lists of A/V pairs). In the latter case, the parentheses around the list are optional.

Radtest statement: expect code [expr-or-pair-list]
Test if REPLY_CODE matches code and, optionally, if REPLY matches expr-or-pair-list. If so, print the string `PASS', otherwise print `FAIL'.

See section 13.2.8 Interacting with Radius Servers, for the detailed discussion of this statement.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Sergey Poznyakoff on November, 20 2004 using texi2html