NetWare 6.x Conditional Console Scripting Commands

  • 3136456
  • 20-May-2007
  • 16-Mar-2012

Environment

NetWare 6.0
NetWare 6.5

Situation

Require the ability to perform checking within NCF files for determining what events and when events should occurs when specific conditions are met.

Resolution

Conditional Console Scripting Commands: %do, %env, %if, %reset, %while
This document contains console command syntax and usage examples for each command. These commands can be used in NCF files for performing conditional checks, at a basic scripting level.
Condition Command Variables:

Variable Name Description

servername Name of the server
major Server major version number
minor Server minor version number
rev Server revision number
lang Server language ID
utctime Current Server utc time
month Current month 0 (Jan.) - 11 (Dec.)
year Current year
day Current day 1 - 31
hour Current hour 0 - 23
minute Current minute 0 - 59
second Current second 0 - 59
weekday Current day of the week 0 (Sun.) - 6 (Sat.)
srvuptime Number of seconds the server has been up
srvworkingstatus Server working status indicator (5 is a fully operating server)
srvdownflag Server down flag indicator 0 - 1

Notes on commands:
"ENV" (environment) command allows checking for a NULL text string:
example: %if env %servername=="" then cmd load monitor

"cmd" allows passing of an environment variable and having this expand to become part of the command to execute:
example: %if env %major==5 then cmd load [env %modulename]

Note that environment variables within a "cmd" (command) action requires square brackets so indicate environment variable lengths.

"env" (environment) command allows passing of a variable that is not defined and allows actions to be taken if this is the case:
example: %if !env %testvar then cmd load monitor

copy_and_convert_env returns a numerical value.

Some of these features were only available from NetWare 6.5sp1 and NetWare 6sp4
%do


Syntax: %do (action) while (condition)

Conditional Logic: == != >>= <<=

Actions:
cmd set env

Conditions:
nlminfo set env

Values:
numerical - maybe decimal (0) or hex (0x...)
text - text must be double quoted "text"

More help is available by typing 'help %do condition|action'

Cmd Action

%do (cmd update.ncf) while (set "allow lip"!="on")
%do (cmd delay 5) while (env major<6)

Set Condition\Action

%do (cmd ...) while (set "bindery context"==0)
%do (set "application"=="yes") while (env name!=1)

Env Condition\Action

%do (cmd ...) while (env testor!=0)
%do (env myname=1) while (env testif=="false")

Nlminfo Condition

%do (cmdenv %nlm) while (nlminfo *)
%do (cmdenv %nlm) while (nlminfo portal:major > 2)

%env

Global Environment Variables

Variable Definition:
%env name=value
%env name="text"

Variable Current value:
%env name

Delete Variable
%env name=

%if env %major==5 then cmd edit sys:\[env %major].txt

or

%if env %major==5 then cmd load [env %modulename]

%if

Syntax: %if condition then action

Conditional Logic: == != >>= <<=

Conditions:
loaded set env search nlminfo

Actions:
cmd set env

Values:
numerical - maybe decimal (0) or hex (0x...)
text - text must be double quoted "text"

More help is available by typing 'help %if condition|action'

Loaded Condition

%if !loaded portal then cmd unload portal
%if loaded nlmName&nlmName then env iamalive=1
%if loaded !nlmName&nlmName then cmd busy.ncf

Set Condition\Action

%if set "allow lip"=="on" then cmd set "allow lip"="off"
%if set "alert message nodes">20 then cmd more.ncf

Env Condition\Action

%if env %name=="nlm" then cmd load nlm
%if env %name>=5 then set "more nodes"=50


Search Condition

%if search * == "c:\dos" then cmd echo c:\dos is an active search path
%if search 1 == "sys:\system" then env my_load_path="sys:\system"
%if search 1 != "sys:\public" then cmd #search path using bad load are

Nlminfo Condition

%if nlminfo nlmname:major==5 then cmd replace nlmname
%if nlminfo nlmname:minor<5 then cmd next.ncf
%if nlminfo nlmname:rev>5 then env aok=1
%if nlminfo nlmname:month>=6 then cmd unload nlmname
%if nlminfo nlmname:day<15 then cmd unload nlmname
%if nlminfo nlmname:year==2001 then set "my set"=2001
%if nlminfo nlmname:lang!=4 then cmd badlang.ncf
%if nlminfo nlmname:loadpath=="sys:\system" then cmd reload.ncf

Cmd Action

%if set "allow lip"=="on" then cmd echo allow lip is on
%if env major<6 then cmd down

%reset

Delete all user defined global environment variables
Syntax: %reset

%while

Syntax: %while (condition) {action}

Conditional Logic: == != >>= <<=

Conditions:
loaded env nlminfo set

Actions:
cmd set env

Values:
numerical - maybe decimal (0) or hex (0x...)
text - text must be double quoted "text"

More help is available by typing 'help %while condition|action'

Loaded Condition/Action

%while (loaded !portal) {cmd ...}
%while (loaded nlmName&nlmName) {env iamalive=1}

Env Condition/Action

%while (env testor!=0) {cmd ...}
%while (env testif=="false") {cmd delay 5}

Nlminfo Condition/Action

%while (nlminfo *:lang != 4) {cmd env nlm}

Set Condition/Action

%while (set "bindery context"==0) {cmd ...}
%while (set "application"=="yes") {cmd delay 5}

Additional Information


Formerly known as TID# 10087644