BatMan.NLM
('BATMAN' stands for 'Batch File Manager')


Overview


Purpose:		Run batch jobs on file servers


Short Description:	
	BATMAN.NLM allows you to run one or more batch files on the server. The batch files may include many DOS and NetWare commands plus all Console commands (e.g., DIR, COPY, LOGIN, USERLIST, MOUNT, etc.) and control structures (like IF ERRORLEVEL, GOTO, GOSUB, etc.)
	While NetWare NCF-files may only contain console commands, BATMAN allows to include DOS/NetWare commands, too.


Author:		Dr. Wolfgang Schreiber


Syntax:		LOAD BATMAN <batch file name>
			(e.g., LOAD BATMAN SYS:SYSTEM\myjob.bat)


Batch Commands and Syntax:
	BATMAN accepts a wide variety of DOS and NetWare commands, and may in addition to this use its own control commands to provide additional features.
	Most of the commands have a similar syntax as their corresponding DOS or NetWare equivalents. See the complete syntax descriptions for details.


So, what's the difference?
	While you always have the option of writing your own NCF files, and there are also some command shells for servers available, BATMAN gives you the possibility to use  . . . 
	... not only all NetWare console commands, but also
	... many standard DOS commands like COPY, REN, TYPE, DEL, CLS, CD
	... many NetWare commands like ATTACH, MAP, USERLIST, SLIST, WHOAMI
	... attachments to remote servers
	... control commands like IF, PAUSE, GOSUB, RESTART, SKIP
	... execution time control with DELAY, PAUSE, SET PRIORITY, WAIT
	... operator interaction with commands like INPUT
	... up to twenty parallel batch jobs
	to provide you with the tools for simple or complex batch programming on NetWare servers.




Table of Contents


	Overview	1
		Batch Commands and Syntax:	1
		So, what's the difference?	1

	Table of Contents	3

	Available Commands	5
		ATTACH	Attach to remote server	5
		BEEP	Beep on server	5
		CALL	Call/Spawn child batch job	6
		CD	Change directory	6
		CHDIR	Change directory	7
		CLRSCR	Clear Screen	7
		CLS	Clear Screen	7
		COPY	Copy files	7
		DATE	Show Current Date & Time	8
		DEBUG	Toggle Debug Mode	8
		DEL	Delete files	8
		DELAY	Pause (in seconds)	9
		DIR	List dir/file names	9
		DISPLAY	Control screen output	9
		ECHO	Display text	11
		ERASE	Delete Files	11
		EXISTS	Check if file/dir exists	11
		EXIT	End program	12
		FLAG	Set file attributes	12
		GLIST	List groups	12
		GOSUB	Call subroutine	13
		GOTO	Jump to label	13
		GROUPLIST	List groups	13
		HELP	Show help screens	14
		IF [not] ERRORLEVEL  . . . 	Execution dependent on errorlevel	14
		IF [not] EXIST  . . . 	Execution dependent on existence	14
		IF [not] <x1>==<x2>  . . . 	Execution dependent on comparison	15
		INPUT	Wait for and execute operator command	15
		INPUT <v>	Enter Local Environment Variable	15
		INPUT <#v>	Enter Global Environment Variable	16
		LIST	List current batch file	16
		LOGIN	Login to local or remote server	17
		LOGOUT	Disconnect from server	17
		LOOP 	Execute set of command lines for each object	18
		MAP	Show/Define drive mapping	19
		MD	Create new directory	19
		MKDIR	Create new directory	19
		MOVE	Move files	20
		NCOPY	Copy files	20
		NDIR	List dir/file names	20
		NPRINT	Print to queue	21
		PAUSE	Pause batch execution	21
		PRINT	Print to queue	21
		QLIST	List print queues	22
		QUEUELIST	List print queues	22
		RD	Delete directory	22
		REM	Comment line	22
		REN	Rename files	23
		RENAME	Rename files	23
		RESTART	Restart current batch job	23
		RETURN	Return from GOSUB	24
		RMDIR	Delete directory	24
		SET	Display environment variables	24
		SET <v>	Set global or local environment variable	24
		SET PRIORITY	Set batch priority	25
		SKIP	Skip batch lines	25
		SLIST	List file servers	26
		TIME	Show current date & time	26
		TYPE	Type text file	27
		ULIST	List users	27
		USERLIST	List users	28
		VER	Show BATMAN.NLM date/version	28
		WAIT	Wait until given date and/or time	28
		WHOAMI	Show current server attachments	29
		#	Comment	29
		;	Comment	29
		?	Show help screens	30
		:<str>	Label for GOTO/GOSUB	30
		*<str>	Execute console command	30
		<drv>:	Change drive/server	31

	Use of Variables	33

	Basic Examples	35

	Advanced Examples	37

	Limitations	39

	Error Codes	41



Available Commands




ATTACH	Attach to remote server

Syntax:	ATTACH <server>[/<user>[;<password>]]

Comments:	This command allows you to login/attach to your local or to a remote server. You have to be logged into a server before being able to map a drive to that server or to utilize its resources (e.g., to access print queues).
	Logging into your local server is not required, since the initial connection will be logged in as SUPERVISOR unless you explicitly logout or login with another user name.
	If no password is specified, BATMAN will try to login without a password. If this login attempt fails, BATMAN will prompt you to enter a password.
	If no user name is specified, BATMAN will ask you to enter a user name.
	You may be logged in or attached to a maximum of 10 file servers per batch job.
	If ATTACH has to ask for a user name and/or password, it will implicitly call 'Display Open' and 'Display Start' to allow visible input.  If required, you should explicitly close/stop the display, then.

Return Code:	none

Example(s):	a)	ATTACH FS2/SUPERVISOR;SECRET
	b)	ATTACH FS2/SUPERVISOR
	c)	ATTACH FS2

See also:	LOGIN, LOGOUT, WHOAMI



BEEP	Beep on server

Syntax:	BEEP

Comments:	Create a beeping sound at the server console to attract the operator's attention.

Return Code:	none

Example(s):	a)	IF Errorlevel 1 beep
	b)	beep
		input

See also:	DELAY, PAUSE, WAIT



CALL	Call/Spawn child batch job

Syntax:	CALL <path/file>

Comments:	This command spawns a new batch file as child process. The  new process receives its own server screen and is completely independent of the parent batch job.
	Unlike DOS, the parent batch job does not wait until the child batch finishes, but immediately continues its operation. There is no direct communication between parent and child processes.
	Use this command to run more than one batch job in parallel.

Return Code:	0	child was spawned successfully
	1	child could not be started (bad file name, insufficient resources)

Example(s):	CALL F:\TEMP\newbatch.bat

See also:	EXIT, GOSUB



CD	Change directory

Syntax:	CD <path>

Comments:	Change path for the current directory.  The CD command will only affect the current working directory.  Unlike the DOS/NetWare  command it will not change the location of the current mapping.
	CD cannot be applied to other drives/mappings, i.e., the syntax "CD F:\TMP" is not accepted. You must insert a blank between the CD command and the path - "CD.." will not be recognized, "CD .." is the correct syntax.

Return Code:	0	Success
		for other errors see the appendix


Example(s):	a)	CD \TEMP\DAT
	b)	CD ..

See also:	CHDIR, RD, MD



CHDIR	Change directory

Syntax:	see CD

Comments:	see CD



CLRSCR	Clear Screen

Syntax:	see CLS

Comments:	see CLS



CLS	Clear Screen

Syntax:	CLS

Comments:	This command clears the batch job's current screen.

Return Code:	none

See also:	CLRSCR, DISPLAY, ECHO, POPUP



COPY	Copy files

Syntax:	COPY <source path/file> <target path/file>

Comments:	Copy one or multiple files from the source path to the target.
	Source and target paths may include file server names, volumes, mappings, and local server drives.
	The source path may include wildcards. Source and target paths may include local DOS, NetWare and remote NetWare directories. COPY and NCOPY have identical functionality.

Return Code:	0	Success
		for other errors see the appendix


Example(s):	a)	COPY SYS:SYSTEM\*.LOG F:
	b)	COPY FS2/VOL2:DATA\TEST.DAT C:\NW312\

See also:	MOVE, NCOPY, TYPE



DATE	Show Current Date & Time

Syntax:	DATE

Comments:	This command displays the current server date and time.

Return Code:	No change on success 

See also:	TIME, WAIT



DEBUG	Toggle Debug Mode

Syntax:	DEBUG

Comments:	This command is for debugging purposes, only. You can use its output to report problems/bugs to the author.

	The command acts as a toggle switch: Calling it once will turn debugging on, calling it again will turn debug mode off.  Initially debug mode is turned off.
	Debug mode is global: it affects all parallel batch jobs.

Return Code:	none



DEL	Delete files

Syntax:	DEL <file/path>

Comments:	Delete one or multiple files. The <path/file> specification may include server names, volumes, mappings, and wildcards.
	DEL will not ask for confirmation.

Return Code:	0	Success
	13	Invalid Path
	90	Invalid Syntax
		for other errors see the appendix

Example(s):	a)	DEL SYS:SYSTEM\NET$ACCT.DAT
	b)	DEL F:\TEMP\*.*

See also:	ERASE



DELAY	Pause (in seconds)

Syntax:	DELAY <seconds>

Comments:	This command will delay batch execution for the specified number of seconds. The number of second may be any positive number of type int.
	If an invalid number of seconds are passed, execution will continue without delay.

Return Code:	No change on success 
	90	Invalid Syntax

Example(s):	a)	rem Wait 1 hour
		DELAY 3600
	b)	DELAY 1

See also:	BEEP, PAUSE, SET PRIORITY, WAIT



DIR	List dir/file names

Syntax:	DIR <path/file>

Comments:	List files and directories that match a given pattern.

Return Code:	0	Success
	1	no files found / invalid path
	13	Invalid Path
		for other errors see the appendix

Example(s):	a)	DIR *.NLM
	b)	DIR F:\PUBLIC

See also:	NDIR, TYPE



DISPLAY	Control screen output

Syntax:	DISPLAY STOP

Comments:	Do no longer display messages on the screen. Redirect further output to NULL. The batch Screen will still be visible and accessible with normal server commands, but no further output will be displayed until this is reenabled by the batch job, e.g., by the command DISPLAY START.

Syntax:	DISPLAY START

Comments:	Restart displaying output again, after it had been stopped with DISPLAY STOP. The batch job's screen will restart displaying the job activity, but the currently displayed screen does not change. If this is desired, an additional DISPLAY POPUP is required.
	If the screen is closed, the command has no effect.

Syntax:	DISPLAY CLOSE

Comments:	Stop displaying batch results and close the batch screen. The batch Screen is no longer visible or accessible, no more output will be displayed, and BatMan's main screen will be displayed.
	Use this command with care, because the only means of restarting the display is from within the batch job. The screen can be reopened by DISPLAY OPEN, DISPLAY START, or by a command that requires user input, e.g., INPUT, or ATTACH. DISPLAY CLOSE will implicitly call DISPLAY STOP.

Syntax:	DISPLAY OPEN

Comments:	After a batch screen has been closed, recreate the screen and restart output again. If the screen was already open, the command has no effect.  If the screen was closed, the command will also resume displaying the output - an extra DISPLAY START is not required.

Syntax:	DISPLAY POPUP

Comments:	Let the current batch screen be the visible screen on the console. You may use this command


	DISPLAY OPEN/CLOSE can be used to close and reopen the screen of a batch job. By default every job receives its own screen.
	DISPLAY START/STOP allows to hide the output for selected sections of a job.
	BatMan's main screen will however always show the currently active batch line for all active batch jobs, even if the display is turned off.

	Commands that require user input (e.g., INPUT, or ATTACH/LOGIN) will automatically reactivate a screen and continue the display.

Return Code:	No change on success 
	1	Insufficient resources

Example(s):	a)	DISPLAY CLOSE
	b)	DISPLAY POPUP

See also:	CLS, ECHO, INPUT, TYPE



ECHO	Display text

Syntax:	ECHO ON|OFF|<text>

Comments:	ECHO is used to display short messages on the screen. It can also be used to display error levels returned by previous commands.
	You may use variables in ECHO statements as well as in other commands.
	If you use ECHO OFF the command lines will no longer be displayed before they are executed; if ECHO is ON, BatMan will show the command before showing its results.

Return Code:	none

Example(s):	a)	ECHO Now copying the data  . . . 
	b)	ECHO The last command returned error level %ERR%

See also:	CLS, DISPLAY, TYPE, Use of Variables



ERASE	Delete Files

Syntax:	see DEL

Comments:	see DEL



EXISTS	Check if file/dir exists

Syntax:	EXISTS <path/file>

Comments:	This command can be used to determine if a file or directory exists.

Return Code:	0	path/file exists
	1	path/file does not exist

Example(s):	EXISTS Z:\PUBLIC\MY.DAT

See also:	IF EXISTS



EXIT	End program

Syntax:	EXIT [CLOSE]

Comments:	This command immediately ends the batch job.  Unless the option CLOSE is specified, the screen stays open and waits for a key stroke to be closed. If the option CLOSE is specified, the batch job screen will be closed, otherwise the screen will be closed after a keystroke.

Return Code:	none

Example(s):	a)	EXIT
	b)	EXIT CLOSE

See also:	DISPLAY



FLAG	Set file attributes

Syntax:	FLAG <path> <attr>

Comments:	not yet implemented

Return Code:	none

Example(s):	-

See also:	-



GLIST	List groups

Syntax:	GLIST [<search pattern>]

Comments:	GLIST lists all defined groups matching the specified pattern. If no pattern is specified, all groups are listed.

Return Code:	0	At least one matching group found
	1	No matching group found

Example(s):	a)	GLIST
	b)	GLIST EDU*

See also:	GROUPLIST, OLIST, QLIST, SLIST, ULIST



GOSUB	Call subroutine

Syntax:	GOSUB <label>

Comments:	The command executes a subroutine. The command executor jumps to the line defined as ":<label>" and returns as soon as a "RETURN" statement is found in the subroutine.

Return Code:	No change on success 
	5	Unknown Label
		for other errors see the appendix

Example(s):	GOSUB MyProg

See also:	CALL, GOTO, RESTART, RETURN



GOTO	Jump to label

Syntax:	GOTO <label>

Comments:	The command executor jumps to the line defined as ":<label>".

Return Code:	No change on success 
	5	Unknown Label
		for other errors see the appendix

Example(s):	GOTO NextStep

See also:	GOSUB, SKIP



GROUPLIST	List groups

Syntax:	see GLIST

Comments:	see GLIST



HELP	Show help screens

Syntax:	HELP

Comments:	This command show a list of available commands. Its main use is to get help in interactive menus.

Return Code:	none

See also:	?



IF [not] ERRORLEVEL  . . . 	Execution dependent on errorlevel

Syntax:	IF [not] ERRORLEVEL <level> <command>

Comments:	Selective execution of specified commands. <Command>  will be executed if the current errorlevel is [not] equal to or higher than the specified level.
	Execute on error: 		If Errorlevel 1 <cmd.>
	Execute on success: 		If Not Errorlevel 1 <cmd>

Return Code:	dependent on executed command

Example(s):	a)	IF ERRORLEVEL 1 BEEP
	b)	IF NOT ERRORLEVEL 1 GOSUB MySub

See also:	ECHO, EXISTS, GOTO



IF [not] EXIST  . . . 	Execution dependent on existence

Syntax:	IF [NOT] EXIST <path/file> <command>

Comments:	Selective execution of specified commands. <command>  will be executed if the specified path/file exists [or does not exist, if 'NOT' is specified].

Return Code:	dependent on executed command

Example(s):	a)	IF EXIST F:\TEST.DAT COPY F:\TEST.* H:\
	b)	IF NOT EXIST C:\CONFIG.SYS beep
	c)	IF NOT EXISTS VOL3:VOL$ERR.LOG *mount VOL3

See also:	EXISTS, GOTO



IF [not] <x1>==<x2>  . . . 	Execution dependent on comparison

Syntax:	IF [NOT] <x1>==<x2> <command>

Comments:	Execute command dependent on comparison of two strings

Return Code:	dependent on executed command

Example(s):	a)	IF %A==WSCHREIB GOTO MyWork
	b)	IF %ERR%==00D3  Echo No Queue Rights
	c)	IF "%1"==""  Echo *** Incorrect syntax ***

See also:	GOTO, INPUT, SET, Use of Variables



INPUT	Wait for and execute operator command

Syntax:	INPUT

Comments:	This commands waits for user input and executes the command entered. It accepts all commands including console commands or conditional jumps; only labels entered will be ignored.
	If the display is paused or closed with the DISPLAY command, INPUT will implicitly call 'DISPLAY OPEN' and 'DISPLAY START' to allow visible input.  If required, you should explicitly close/stop the display.

Return Code:	Dependent on given command

Example(s):	:Loop
	ECHO Enter any command
	INPUT
	GOTO Loop

See also:	INPUT <v>, INPUT <#v>, SET



INPUT <v>	Enter Local Environment Variable

Syntax:	INPUT <v>

Comments:	This commands waits for user input and stores the string entered in the specified environment variable. BATMAN accepts the 26 one character environment variables named 'A'-'Z'.  These variables can be utilized during future program execution.
	The variables can be used in any batch command and will be replaced by their contents before the command line is parsed.
	Local variables are stored separately for each batch job and are not shared between parallel batch jobs: If one batch job modifies a local variable, other jobs are not affected.

Return Code:	No change on success 

Example(s):	ECHO Enter User Name
	INPUT N
	LOGIN FS3/%N

See also:	IF, INPUT, INPUT <#v>, SET, Use of Variables



INPUT <#v>	Enter Global Environment Variable

Syntax:	INPUT <#v>

Comments:	This commands waits for user input and stores the string entered in the specified environment variable. BATMAN accepts the 26 one character environment variables named 'A'-'Z'.  These variables can be utilized during future program execution.
	The variables can be used in any batch command and will be replaced by their contents before the command line is parsed.
	Global variables are shared between parallel batch jobs: As soon as one batch job modifies the global variable, other jobs can access its contents. You may use global variables for job-to-job communication, and to synchronize batch jobs.

Return Code:	No change on success 

Example(s):	a)	ECHO Enter User Name
		INPUT #N
		LOGIN FS3/%#N
	b)	IF not "%#N"=="" GOTO NameOK
		Echo Input Name
		Input #N
		:NameOK
		Login FS4/%#N

See also:	IF, INPUT, INPUT <v>, SET, Use of Variables



LIST	List current batch file

Syntax:	LIST

Comments:	This command displays the contents of the current batch job as stored in server memory.

Return Code:	No change on success 

See also:	TYPE



LOGIN	Login to local or remote server

Syntax:	LOGIN [srv[/usr[;pwd]]]

Comments:	This command allows you to login to the local or to a remote server with a specified user name.  A maximum of 10 server attachments is available per batch job.  Each login will use one connection on the remote server; to release the connections call LOGOUT.
	LOGIN will implicitly call 'Display Open' and 'Display Start' to allow for visible input, if user input (e.g., user name or password) is required. You might want to  explicitly close/stop the display after calling LOGIN.

Return Code:	0	Success
		for other errors see the appendix

Example(s):	a)	LOGIN
	b)	LOGIN FS2/SUPERVISOR
	c)	LOGIN BIG_ONE/GUEST;SECRET

See also:	ATTACH, LOGOUT, MAP, WHOAMI



LOGOUT	Disconnect from server

Syntax:	LOGOUT [server name]

Comments:	This command can be used to release the connection to one or more remote file servers or to the local server.
	Be aware that each parallel batch job maintains its own connection table, and receives its own connection on the server. If all 20 parallel jobs are logged into a server, they will use up 20 connections. It may therefor be useful to release connections that are no longer needed.

Return Code:	0	Success
		for other errors see the appendix

Example(s):	a)	LOGOUT
	b)	LOGOUT FS4

See also:	ATTACH, LOGIN, WHOAMI



LOOP 	Execute set of command lines for each object

Syntax:	LOOP <obj> <pattern>

Comments:	Use this command to execute a sequence of batch lines for each object. Replace the term <obj> by one of  Ux' (users),  Gx' (groups),  Qx' (queues),  Sx' (servers),  Ox' (all objects), where  x' is a number between 0 and 9, e.g.,  U1'.
	BatMan will scan the bindery for all objects matching the specified search pattern <pattern>.  
	BatMan will store the current object's name, ID, and type in a variable and allows you to access the variable data during the further batch process. The name of the variable will be the same as  <obj>' specified. The variable fields are NAME, ID, and TYPE.
	BatMan will return to the initial loop statement when a label named  :<obj>' is encountered..
	Example: You have entered the line sequence
		LOOP G1 *
		echo %G1.NAME% %G1.ID%
		md SYS:\%G1.NAME%
		:G1
	For each existing group BatMan will loop once through these 4 lines. BatMan will display group name, and ID, and will then create a subdirectory for every group.

	Loops with different variable names may be nested.

Return Code:	0	Success
		for other errors see the appendix

Example(s):	a)	LOOP U2 *
		echo %U2.NAME% %U2.ID% %U2.TYPE%
		:U2

	b)	Loop U1 *
		Loop U2 *
		Echo %U1.Name% %U2.Name%
		:U2
		:U1

See also:	ULIST, GLIST, QLIST, SLIST



MAP	Show/Define drive mapping

Syntax:	MAP [<drv>:[=<path>]]

Comments:	You may define mappings to the local server or to remote servers.  Mappings basically serve the purpose to more easily access local or remote paths.
	Before mapping drives to remote servers you must be attached to that server.
	Unlike the behavior of NetWare's MAP command, the definitions will not be changed by a CD command.
	Logging out from a server deletes all mappings to that server.

Return Code:	0	Success
		for other errors see the appendix

Example(s):	a)	MAP
	b)	MAP f:
	c)	MAP K:=MERLIN/SYS:PUBLIC

See also:	ATTACH, CD, LOGIN



MD	Create new directory

Syntax:	MD <path>

Comments:	MD creates a new directory.

Return Code:	0	Success
	13	Invalid Path
		for other errors see the appendix

Example(s):	a)	MD temp
	b)	MD F:\HOME\Temp

See also:	CD, MAP, RD



MKDIR	Create new directory

Syntax:	see MD

Comments:	see MD



MOVE	Move files

Syntax:	MOVE <source path/file> <target path/file>

Comments:	Move one or multiple files from the source path to the target. Files will first be copied, after successful copy process the source file will be deleted.
	Source and target paths may include file server names, volumes, mappings, and local server drives.
	The source path may include wildcards.

Return Code:	0	Success
		for other errors see the appendix

Example(s):	a)	MOVE SYS:SYSTEM\*.LOG F:
	b)	MOVE FS2/VOL2:DATA\TEST.DAT C:\NW312\

See also:	COPY, NCOPY, TYPE



NCOPY	Copy files

Syntax:	<source path/file> <target path/file>

Comments:	Copy one or multiple files from the source path to the target.
	Source and target paths may include file server names, volumes, mappings, and local server drives. The source path may include wildcards. Source and target paths may include local DOS, NetWare and remote NetWare directories.
	COPY and NCOPY have identical functionality.

Return Code:	0	Success
		for other errors see the appendix

Example(s):	a)	NCOPY SYS:SYSTEM\*.LOG F:
	b)	NCOPY FS2/VOL2:DATA\TEST.DAT C:\NW312\

See also:	COPY, MOVE, TYPE



NDIR	List dir/file names

Syntax:	NDIR <path/file>

Comments:	see NDIR



NPRINT	Print to queue

Syntax:	NPRINT <path/file>

Comments:	not yet implemented

Return Code:	0	Success
		for other errors see the appendix

Example(s):	

See also:	



PAUSE	Pause batch execution

Syntax:	PAUSE [message]

Comments:	The command switches the display on, if it was switched off with DISPLAY STOP or DISPLAY CLOSE; then it will display the optional message and "Press Any Key to Continue  . . . ".  Program execution will not continue until the operator presses a key.

Return Code:	No change on success 

Example(s):	a)	PAUSE
	b)	PAUSE Please insert CD-ROM
	c)	DISPLAY Popup
		Beep
		Pause Insert Floppy Now  . . . 

See also:	BEEP, DELAY, DISPLAY, SET PRIORITY, WAIT



PRINT	Print to queue

Syntax:	see NPRINT

Comments:	see NPRINT



QLIST	List print queues

Syntax:	QLIST [<search pattern>]

Comments:	QLIST lists all defined queues matching the specified pattern. If no pattern is specified, all queues are listed.

Return Code:	0	At least one matching queue found
	1	No matching queue found

Example(s):	a)	QLIST
	b)	QLIST PR*

See also:	GLIST, OLIST, QUEUELIST, SLIST, ULIST



QUEUELIST	List print queues

Syntax:	see QLIST

Comments:	see QLIST



RD	Delete directory

Syntax:	RD <path>

Comments:	Remove

Return Code:	0	Success
	13	Invalid Path
		for other errors see the appendix

Example(s):	RD F:\temp

See also:	CD, MAP, MD



REM	Comment line

Syntax:	REM <string>

Comments:	Use this command to add comments to your batch jobs.

Return Code:	none

Example(s):	REM Batch job to synchronize servers

See also:	 #',  ;',  :'



REN	Rename files

Syntax:	REN <path/file> <new name>

Comments:	Use this command to rename files.

Return Code:	0	Success
	13	Invalid Path
		for other errors see the appendix

Example(s):	REN f:\temp\abc.dat def.dat

See also:	COPY, MOVE, TYPE



RENAME	Rename files

Syntax:	see REN

Comments:	see REN



RESTART	Restart current batch job

Syntax:	RESTART

Comments:	RESTART will continue the execution of the current batch job with the first batch line. It has the same effect as SKIP -999, or as a GOTO jump to a label on the first batch line.

Return Code:	none

Example(s):	RESTART

See also:	GOSUB, GOTO, RETURN, SKIP




RETURN	Return from GOSUB

Syntax:	RETURN

Comments:	The return statement ends a GOSUB subroutine and returns to the line following the GOSUB statement that was last executed.

Return Code:	No change on success 

	97	No Gosub

Example(s):	RETURN

See also:	GOSUB, RETURN, RESTART, SKIP



RMDIR	Delete directory

Syntax:	see RD

Comments:	see RD



SET	Display environment variables

Syntax:	SET

Comments:	This command shows all local and global environment variables. This includes local and global, user definable and system variables.

Return Code:	No change on success 

Example(s):	SET

See also:	ECHO, IF, INPUT, SET <v>, Use of Variables



SET <v>	Set global or local environment variable

Syntax:	SET [#]<v>

Comments:	This command defines or deletes local or global environment variables. Only one letter variables (A-Z) are allowed. Global variables are identified by a leading  #'.
	While local variables are visible only from within the current batch job, global variables are shared among all parallel batch jobs. The effect of changing a global variable in one job will immediately affect all parallel jobs. You may use global variables to exchange information between jobs and to synchronize jobs.

Return Code:	No change on success 

Example(s):	a)	Set A=MAINSRV
		Login %A/SUPERVISOR
		MAP F:=%A/SYS:PUBLIC
	b)	;Store Errorlevel
		SET A=%ERR%
	c)	SET #A=World
		Echo "Hello %#A"

See also:	ECHO, IF, INPUT, Use of Variables



SET PRIORITY	Set batch priority

Syntax:	SET PRIORITY [High|Low]

Comments:	Use this command to take influence on the priority NetWare assigns to a batch job.  By default jobs start with high priority.  NetWare will assign slightly less CPU cycles to a batch job that is set to low priority. If you wish, you can reduce or increase priority temporarily by using this SET command.
	"SET PRIORITY" will show the current job priority.

Return Code:	none

Example(s):	a)	SET Priority
	b)	SET Priority Low

See also:	DELAY, PAUSE, WAIT



SKIP	Skip batch lines

Syntax:	SKIP [-]<nr>

Comments:	While the command GOTO will execute an absolute jump to the specified address, SKIP will perform a relative jump ahead or back - dependent on the number passed as parameter. 
	"SKIP -1" will continue with the previous line;
	"SKIP 1" ignores the following line.
	Usually you can get the same results with labels and absolute jumps.
	If the relative jump goes to a negative address, the 1st job line will be executed; skipping to an address beyond the end of the job will end the job.

Return Code:	No change on success 

Example(s):	a)	IF not Errorlevel 1 SKIP 1
		Echo Error %ERR% occurred
	b)	SKIP -4
	c)	REM Command Shell
		INPUT
		SKIP -1
	c)	SKIP -999

See also:	GOSUB, GOTO, RESTART, RETURN



SLIST	List file servers

Syntax:	SLIST [<search pattern>]

Comments:	SLIST lists all defined file servers matching the specified pattern. If no pattern is specified, all servers are listed.

Return Code:	0	At least one matching server found
	1	No matching server found

Example(s):	a)	SLIST
	b)	SLIST FS*

See also:	GLIST, OLIST, QLIST, ULIST



TIME	Show current date & time

Syntax:	TIME

Comments:	The command will display the local server's date and time. The command is equivalent to DATE.

Return Code:	none

Example(s):	TIME

See also:	DATE, DELAY, PAUSE, WAIT



TYPE	Type text file

Syntax:	TYPE <path/file>

Comments:	Use this command to display the contents of text files on the job screen.  You may use this to show extensive information, or to interactively browse files. TYPE will halt after each displayed page and ask for a key stroke before showing the next page.
	If DISPLAY is turned off, the command will be ignored and will not even verify the file's existence.

Return Code:	0	Success
	13	Invalid Path

Example(s):	TYPE C:\AUTOEXEC.BAT

See also:	ECHO, DISPLAY



ULIST	List users

Syntax:	ULIST [<search pattern>]

Comments:	ULIST lists all defined users matching the specified pattern. If no pattern is specified, all users are listed.  Unlike the NetWare utility this command lists all users that are defined, even if not logged in.

Return Code:	0	At least one matching user found
	1	No matching user found

Example(s):	a)	ULIST
	b)	ULIST TEMP*

See also:	GLIST, OLIST, QLIST, SLIST, USERLIST



USERLIST	List users

Syntax:	see ULIST

Comments:	see ULIST



VER	Show BATMAN.NLM date/version

Syntax:	VER

Comments:	This command displays the name and creation date/time stamp of BatMan.NLM.

Return Code:	none

Example(s):	VER

See also:	-



WAIT	Wait until given date and/or time

Syntax:	WAIT <time/date string>

Comments:	WAIT compares the time/date string passed as parameter with the current date/time string; the batch execution halts until the parameter string is contained in the current time string.  The current date/time string has the following format:
		(mm/dd/yy) [hh:mm:ss]
	You may pass a complete or a partial string to the WAIT command. If you want to wait until the full hour, for example, you might enter
		WAIT 00:00]
	Be careful with WAIT loops that check the time; often you have to insert additional delays to avoid excessive loop runs:
		:Backup
		WAIT [02:00
		*runback.ncf
		WAIT [03:00	
		REM to avoid permanent run between 2:00h-3:00h
		GOTO backup

Return Code:	No change on success 
	27	<ESC> was hit
	90	Invalid Syntax

Example(s):	a)	WAIT [02:30:00]
	b)	WAIT (12/31/99)
	c)	WAIT /01/
		WAIT [23:30:00]
		REM executes nightly the 1st day of the month

See also:	BEEP, DELAY, PAUSE, SET PRIORITY



WHOAMI	Show current server attachments

Syntax:	WHOAMI

Comments:	WHOAMI will display the server names for all current attachments to local and remote servers.

Return Code:	none

Example(s):	WHOAMI

See also:	ATTACH, LOGIN, LOGOUT



#	Comment

Syntax:	# <any text string>

Comments:	Use this command to comment your batch jobs; be aware, however, that the job file may not exceed 1000 lines.

Return Code:	none

Example(s):	# this is a comment and will be ignored

See also:	REM, ;, :<label>



;	Comment

Syntax:	; <any text string>

Comments:	Use this command to comment your batch jobs; be aware, however, that the job file may not exceed 1000 lines.

Return Code:	none

Example(s):	; this is a comment and will be ignored

See also:	REM, #, :<label>



?	Show help screens

Syntax:	?

Comments:	see HELP



:<str>	Label for GOTO/GOSUB

Syntax:	:<string>

Comments:	The label may be used as target for GOSUB and GOTO commands, but also as comments. The label ends at the first blank of the line.  All further characters will be ignored. The maximum label string length is limited only by the maximum line length. Labels are not case sensitive.

Return Code:	none

Example(s):	a)	IF ERRORLEVEL 1 GOTO MyErrorHandler
	b)	:Block3

See also:	GOSUB, GOTO, IF, RESTART, SKIP



*<str>	Execute console command

Syntax:	*<string>

Comments:	Any console command may be entered to the local server's system console.  This will always be sent to the local server, even if the current working directory is on a remote server.
	The string plus a <CR> will be pushed into the server's keyboard buffer of the system console. Independent of what the active (displayed) server screen is, the command will always affect the system console.
	The command might not be executed as expected, when a console operator has partially entered a command, already, without pressing <CR>: the command will be appended to the existing keystrokes, then. To be on the save side you might think about sending an  empty' command with nothing but the <CR>.

Return Code:	0	Success

Example(s):	a)	*LOAD MONITOR
	b)	*
		*BACKUP.NCF
	c)	IF not EXIST VOL1:\ERR$LOG.DAT *mount vol1

See also:	-



<drv>:	Change drive/server

Syntax:	<drv>:

Comments:	This command changes the current working directory to the one defined as the mapping.  When a CD command is entered to change the working directory, this will not modify the mapping.
	Changing the current directory to a DOS partition or floppy drive is not allowed.

Return Code:	0	Success
	13	Invalid Path
	1-26	Error on drive A-Z
	1-10	Error on server 1-10
		for other errors see the appendix

Example(s):	F:

See also:	ATTACH, CD, LOGIN, MAP


Use of Variables

You may use some identifier variables in any batch command.  These variables may be set by an operator or by one of the batch files, or they can be set by the system.
Variables may be used in any batch command and will be replaced by their contents before the command line is parsed.


Types of Variables

There are two types of variables in terms of common access from parallel batch jobs:
	Local variables	These are valid only within one batch job. Another batch job may use the variable with the same name but different contents.
	Global variables	These variables are shared between batch jobs. One batch file may change the contents of the variable and another batch job will see the changes. Global variables with the same name have the same different contents in each job.

In addition to this there are two types of variables in terms of modifiability:
	User variables	These variables may be changed by the user with the INPUT or SET command.
	Loop variables	These variables are defined by using the LOOP command.
	System variables	System variables are set by BATMAN and cannot directly be modified.

BatMan currently supports the following variables:

Var	Set by	Range	Description

%A-%Z	User	Local	These variables may store any string as entered by the user or from a batch job using the SET command. These variables are not shared between parallel batch jobs.
%#A-%#Z	User	Local	These variables may store any string as entered by the user or from a batch job using the SET command. These variables are shared between parallel batch jobs.
%U0-9%	Loop	Local	These variables contain name, IDs, and types of users as specified in the LOOP command.
%G0-9%	Loop	Local	These variables contain name, IDs, and types of groups as specified in the LOOP command.
%Q0-9%	Loop	Local	These variables contain name, IDs, and types of queues as specified in the LOOP command.
%S0-9%	Loop	Local	These variables contain name, IDs, and types of file servers as specified in the LOOP command.
%O0-9%	Loop	Local	These variables contain name, IDs, and types of objects as specified in the LOOP command.
%0-%9	System	Local	These variables store the command line parameters as passed in the CALL command. Use these variables to hand different options to batch jobs and to process these options in the job.
%ERR%	System	Local	This variable stores the errorlevel of the last command that set it.  Not all commands will change the error level. Commands that do not return a return code will not modify the stored error level of the previous command. E.g., labels, comments, console commands do not change the current error level. Check with the command descriptions for possible command error codes.
%DIR%	System	Local	This variable stores the current working directory. The variable includes server name, volume, and path.
%LINE%	System	Local	This variable contains the line number of the batch job command, which is currently executed. You may for example use this variable to display the current batch position to an operator. The first line has the number 1.  The line number will also be displayed in BatMan's main screen.
%JOB%	System	Local	The variable contains the name and path of the batch job that currently is active.


Basic Examples


Manual command entry
	:LOOP
	INPUT
	GOTO LOOP

	This little batch file serves as a 'command shell' for the server, allowing you to enter all BATMAN commands manually.  To terminate the batch file enter 'EXIT'.

Mixing batch commands and console commands
	IF NOT EXISTS VOL3:VOL$ERR.LOG *mount VOL3

Scheduled NLM execution
	WAIT 02:00:00
	*BACKUP.NCF
	
	In this sample BACKUP.NCF represents an NCF file containing server console commands to execute the backup. It will be executed at night at 2am.



Advanced Examples

Monthly Deletion of NetWare's Accounting Data
	MAP K:=SYS:SYSTEM
	:NEXTMONTH
	WAIT /01/
	COPY K:NET$ACCT.DAT K:\TEMP\
	WAIT /02/
	GOTO NEXTMONTH

Collect all user login scripts
	MD \scripts
	LOOP U1 *
	MD \scripts\%U1.NAME%
	copy SYS:\MAIL\%U1.ID% \scripts\%U1.NAME%
	:U1

Execution Dependent on Error Levels
	<any command>
	GOSUB %ERR%
	...
	:0000
	Echo Success
	Return
	:0001
	Echo Error 1
	Return
	:0002
	Echo Error 2
	Return

Synchronize Batch Jobs
	rem Batch Job 1
	copy K:TEST.DOC L:
	IF not errorlevel 1 set #A=OK


	rem Batch Job 2
	:loop
	rem wait for other batch job to signal  OK'
	if %#A==OK GOTO GoOn
	delay 10
	GOTO loop
	:GoOn
	type TEST.DOC


Limitations

	Maximum concurrent jobs	20
	Maximum lines per batch job	1000
	Maximum characters  per line	120
	Maximum server attachments per job	10
	Maximum GOSUB depth	100

	These limits may be lower in reality, if available resources (RAM) are insufficient.



Error Codes

	1	Invalid syntax
	1	No such file or directory
	2	Argument list too big
		Command file not found
		File not found
	3	Path not found
		Invalid command syntax
		Execution format error
	4	Bad file number
		No Gosub
	5	Unknown label
		Not enough memory
		Access denied
	6	Invalid handle
		Permission denied
		Invalid connection ID
	7	Missing parameter
		File exists
	8	Crossdevice link
		Unable to login
		Not enough memory
	9	Cannot open file
		Invalid argument
	10	File table overflow
		Invalid drive
		Invalid environment
	11	Invalid format
		Could not execute
		Too many open files
	12	No space left on device
		Insufficient memory
	13	Invalid path
	14	Cannot write file
	15	Operation aborted
	16	Invalid object
	17	Insufficient resources
	18	Cannot run batch job
		No more files
	19	Cannot create file
	90	Undefined error
	97	Undefined message
	99	Feature not yet implemented
	100	Disk read error
	101	Disk write error
	102	File not assigned
	103	File not open
	128	File In Use 
	129	No More File Handles
	130	No Open Privileges
	131	IO Error Network Disk
	132	No Create Privileges
	133	No Create Delete Privileges
	134	Create File Exists r/o
	136	Invalid File Handle
	137	No Search Privileges
	138	No Delete Privileges
	139	No Rename Privileges
	140	No Modify Privileges
	145	Some Files Renamed Name Exists
	146	No Files Renamed Name Exists
	147	No Read Privileges
	148	No Privileges or r/o
	149	File Detached
	150	Disk write protected
	150	Server Out Of Memory
		Out of Dynamic Workspace
	151	No Disk Space For Spool File
	152	Volume Does Not Exist
		Drive not ready
	153	Unknown command
		Directory Full
	154	Renaming Across Volumes
		CRC data error
	155	Bad drive request
		Bad Directory Handle
	156	Invalid Path
		No More Trustees
		Disk seek error
	157	Unknown media type
		No More Handles
	158	Invalid Filename
		Sector not found
	159	Out of paper
		Directory Active
	160	Directory Not Empty
		Device write fault
	161	Device read fault
		Directory IO Error
	162	Hardware failure
	162	Read File With Record Locked
	163	Bad Disk Number
	164	Unused Disk Number 
	176	All Search Drives Used
	177	Drive Is Not Mapped 
	178	Cant Map Local Drive
	179	Invalid Map Type
	180	Invalid Drive Letter
	181	No Drive Available
	182	Out Of Memory 
	183	No Such Search Drive
	191	Name Space Not Found
	192	No Account Privileges
	193	No Account Balance
	194	Credit Limit Exceeded
	195	Too Many Holds
	197	Intruder Lockout
	198	No Console Operator
	200	Missing EA Key 
	201	EA Not Found 
	202	Invalid EA Handle
	203	EA No Key No Data
	204	EA Number Mismatch 
	205	EA Out Of Range 
	206	EA Bad Dir Num 
	207	Invalid EA Handle
	208	Queue Error
	      	EA Out Of Range 
	209	No Queue
		EA Access Denied 
	210	No Queue Server
	      	Data Page Odd Size 
	211	No Queue Rights
		EA Volume Not Mounted
	212	Queue Full
		Bad Page Boundary
	213	No Queue Job
		Inspect Failure
	214	No Job Rights
		EA Already Claimed 
		Encrypted Password Expected 
	215	Password Not Unique
		Queue Servicing
		Odd Buffer Size
	216	Password Too Short
		Queue Not Active
		No Scorecards
	217	Login Denied - No Connection
		Station Not Server
		Bad Signature
	218	Unauth. Login Time 
		Queue Halted
		EA Space Limit 
	219	Unauth. Login Station
		Max Queue Servers
		EA Key Corrupt 
	220	Account Disabled
		EA Key Limit 
	221	Tally Corrupt
	222	Password Has Expired - No Grace
	223	Password Has Expired
	232	Not Item Property
		Write Property To Group
	233	Member Already Exists
	234	No Such Member
	235	Not Group Property
	236	No Such Segment
		No Such Set 
	237	Property Already Exists
	238	Object Already Exists
	239	Invalid Name
		Connection Table Full
	240	Wild Card Not Allowed
	241	Invalid Bindery Security
	242	No Object Read Privilege
		No DOS Memory 
	243	No Object Rename Privilege
	244	No Object Delete Privilege
	245	No Object Create Privilege
		Packet Size Too Large
	246	No Property Delete Privilege
		Not Same Local Drive
	247	No Property Create Privilege
		Target Drive Not Local
	248	Already Attached To Server
		No Property Write Privilege
		Not Attached To Server
	249	No Free Connection Slots
		No Property Read Privilege
		Cancel Error
	250	No More Server Slots
		Temp Remap Error
		No Path To Destination Found
	251	Invalid Parameters
		No Such Property
		Unknown Request
		Salvage Unavailable 
	252	Internet Packet Request Cancelled
		Unknown File Server
		Message Queue Full
		No Such Object
	253	Bad Station Number
		Unknown Request
		Field Already Locked
		TTS Disabled
	254	Bindery Locked
		Directory Locked
		Invalid Semaphore Name Length
		Server Bindery Locked
		Spool Directory Error
		Disabled Login
		Timeout Error
		Transaction Ends Record Lock
		Implicit Transaction Active
	255	Bad Printer Error
		Bad Record Offset
		File Extension Errorr
		File Name Error
		Hardware Error
		Invalid Drive Number
		Invalid Initial Semaphore Value
		Invalid Semaphore Handle
		IO Bound Error
		No Files Found Error
		No Response From Server
		No Such Object Or Bad Password
		Path Not Locatable
		Queue Full Error
		Request Not Outstanding
		Transaction Not Yet Written
		No More Matching Files
		Bindery Error
		Explicit Transaction Active
		No Explicit Transaction Active
		Transaction Not Yet Written
		No More Matching
		No Record Found
		Transmit Error
		Capture Is Active 
		Invalid Dir Handle
		Path Already Exists 
		Print Job Already Set 
		No Capture In Effect
	
