ServerMagic Scripting for NetWare Servers

Table of Contents

1. Overview of ServerMagic Scripting
2. Command Line Options
3. Syntax of Script Statements
4. Script File Statements
5. Script Suggestions and Notes
6. Sample Scripts


1.  Overview of ServerMagic Scripting

You can create script files to automate standard ServerMagic tasks. 
ServerMagic has a number of command line options that support the use 
of script files.

A script file is an ASCII file you can create with any text editor. 
ServerMagic executes each command in a script file in order. If 
ServerMagic encounters an error while processing a script file, it 
immediately terminates the script file without further processing and 
logs the error if a log file was specified in the command line.

You can also use ServerMagic scripting to configure remote systems. 
To do so, you must be able to:

--Load ServerMagic on a remote system.
--Launch ServerMagic on a remote system.
--Get feedback as necessary from a log file on the remote system.

It is your responsibility to set up remote access. 



2. Command Line Options

ServerMagic has the following command line options. The order of the 
options in the command line is not significant. Commands can be up to 
180 characters and must be contained on one line. They cannot begin on 
one line and end on the next.

/? - Displays all the available command line switches and the syntax 
and a short description of each. (The /HELP switch does the same thing.)

/CMD - Passes the name of the script file.

	LOAD SMAGIC.NLM /CMD=SCRIPT.TXT

/ERR - Specifies the file to create if the script file terminates with 
an error. If the script file completes successfully, the specified file 
is deleted. An error log is helpful because it is not possible to return 
the error to the process that invoked ServerMagic if a reboot is 
necessary. If you include this switch in a command line, you can write 
a program to verify that the script was completed successfully by 
checking for the existence of the error log. 

Even if this parameter is not used, the error number will appear in the 
log file (if specified by /LOG) along with a text description of the 
error that occurred. To use the error parameter with the above 
parameters, the syntax would be: 

	LOAD SMAGIC.NLM /CMD=SCRIPT.TXT /LOG=RESULTS.LOG /ERR=ERROR.LOG 

/LOG - Specifies the file in which to store output. The output stored in 
the file includes each script command and all that transpired because of 
that command. To specify a log file RESULTS.LOG, the syntax would be:

	LOAD SMAGIC.NLM /CMD=SCRIPT.TXT /LOG=RESULTS.LOG 

The /LOG switch only works in conjunction with the /CMD switch.

PowerQuest recommends that you create a log file whenever you run 
ServerMagic from a script.

IMPORTANT!	Do not create a log file if you are modifying the partition 
containing the log file. The log file is created on the partition from 
which you run ServerMagic. Modifying the partition containing the log 
file will damage the partition. If you need to modify this partition, 
omit the /LOG switch from the command line or direct the log file to 
a floppy drive with /LOG=a:\results.log. 

/NBS - Turns off bad sector checking. This replaces the Set Default Bad 
Sector Test State script command in that the default is always ON unless 
you specify with this parameter.

	LOAD SMAGIC /CMD=SCRIPT.TXT /NBS

/NRF - (No Run File) Specifies the name of a file that, if it exists, 
prevents the script from executing. A command line can contain more than 
one /NRF switch if it makes sense to check for more than one file. If 
you specify a /LOG file or a /ERR file, the /NRF switch can check for 
the existence of these files and prevent the program from running if 
either exist. This switch is helpful to prevent ServerMagic from 
running more than one time.

	LOAD SMAGIC.NLM /CMD=SCRIPT.TXT /LOG=RESULTS.LOG /ERR=ERROR.LOG /NRF=RESULTS.LOG 

/SCO - (Syntax Check Only) Checks the syntax of a script without 
executing the script. Confirms a partition is selected before executing 
an operation, checks the syntax of all the script commands, and ensures 
that volume labels specified in a select partition statement are unique. 
The syntax check cannot detect errors such as trying to move the 
partition without adjacent free space. If the command line defines a 
/LOG file, a successful syntax check posts a statement that the script 
was successful.

	LOAD SMAGIC /CMD=SCRIPT.TXT /SCO /LOG=RESULTS.LOG



3. Syntax of Script Statements

Many script operators are followed by parameters. In presenting the 
syntax for a command statement, the following characters denote how to 
include the parameters in a statement. Do not include the special 
characters when typing the statement.

{ }	Surrounds required parameters
[ ]	Surrounds optional parameters
|	Separates alternate parameters; choose only one

The case of the statements is not significant.

The maximum length of a line is 180 characters terminated with a 
carriage return. A line can contain only one statement, and statements 
must be completed within one line. The script text file allows comments 
in the C++ form (//). These can be included on a full line or after a 
valid statement.

Each operation in the script executes on the currently specified 
partitions.  You must specify all partitions affected by an operation 
before executing the operation.



4. Script File Statements

This section is an alphabetical list of all the script file statements 
with their syntax and descriptions.


Allow Manual Reboot

This command allows the script to run even if ServerMagic cannot 
remotely reboot the machine after making changes. If you plan to use 
this command, it should be the first statement in the script file.

If this command is omitted, ServerMagic terminates the script if it 
contains a command requiring a reboot that ServerMagic cannot perform 
remotely. 


Check

This command checks the current partition for errors.

IMPORTANT!	You should include Check commands for each partition to be 
modified at the beginning of the script. Since the script file 
terminates when a check error is detected, you can prevent ServerMagic 
from starting to make changes that it could not complete.


Copy 

The Copy command should be preceded by the following commands:

--Select Drive {Num}
--Select Partition {PartitionLetter|"Volume Label"|Extended|Next|Previous|Num }
--Select Copy Drive {Num}
--Select Copy Partition {PartitionLetter|"Volume Label"|Next|Previous|Num }

For the Copy command to work correctly, a drive and partition need to be 
selected and a copy drive and copy partition need to be selected.  If 
the selected partition is free space and the partition specified by the 
copy partition is a partition smaller than the free space, this operation
will copy the specified partition to the free space.

If the selected partition is a valid partition and the partition 
specified by the copy partition is a block of free space large enough 
to hold the partition, the copy operation will copy the selected partition
to the specified free space.


Delete {Volume Name|"NO NAME"|"UNKNOWN"|All}

This command deletes the currently selected partition. To prevent 
accidental deletion of partitions containing data, the command must 
contain the name assigned to the partition. 

This requirement does not apply to extended and unformatted 
partitions.

Volume Name - The volume name is required to delete a partition unless 
the partition is either an extended partition or an unformatted 
partition. This is a check to ensure that you are destroying data in 
the proper partition only.

"NETWARE" - Required if the partition is a NetWare partition.

"NO NAME" - Required if the partition label is blank and the partition 
is FAT or HPFS.

"UNKNOWN" - Required if the partition is not FAT or HPFS.

All - All partitions on the currently selected drive and partition will 
be deleted.


Hide

This command hides the currently selected partition. See also "Unhide."


Move NetWare Partition to Another Disk

This command moves a NetWare partition from one physical disk to 
another. Before executing this command, you must define the target 
drive and free space to receive the moved partition (Select Move Drive 
and Select Move Partition).

You cannot move a mirrored partition with a ServerMagic script.


Resize {Max|Min|Value}[/Clustersize={512|1|2|4|8|16|32}]

This command resizes a partition.

Max - Resizes the partition to the maximum possible size, that is, 
incorporates all adjacent free space to the left and right of the 
partition.

Min - Resizes the partition the smallest possible size, that is, the 
smallest number of cylinders that holds the used space within the 
partition.

Using this option can reduce the unused space in the partition to the 
point that programs fail for lack of memory. Under most circumstances, 
you should leave at least several megabytes of unused space within a 
partition to allow for swap files and other temporary files.

Value - Resizes the partition to the value specified (in megabytes).

/Clustersize= - Sets the cluster size for a FAT partition. If omitted, 
ServerMagic uses the smallest possible cluster size. Values include 
512 (bytes) and 1, 2, 4, 8, 16, and 32 kilobytes.


Resize Larger {Max|Min|Value}[/Clustersize={512|1|2|4|8|16|32}]

This command increases the size of a partition by specifying an 
incremental change in size. 

Max - Resizes the partition to the maximum possible size, that is, 
incorporates all adjacent free space to the left and right of the partition.

Min - Resizes the minimum possible, that is, adds one cylinder of data.

Value - Increases the partition by the value specified (in megabytes).

/Clustersize= - Sets the cluster size for a FAT partition. If omitted, 
ServerMagic uses the smallest possible cluster size. Values include 512 
(bytes) and 1, 2, 4, 8, 16, and 32 (kilobytes).


Resize Left Boundary {Max|Min|Value}

This command moves the left boundary of a NetWare or extended partition. 

Max - Moves the boundary of a NetWare or extended partition as far to 
the left as possible (flush with the next partition or the beginning 
of the drive).

Min - Moves the left boundary of a NetWare or extended partition as far 
to the right as possible (lush with the first logical partition).

Value - Moves the boundary of a NetWare or extended partition left by 
the amount of the value specified (in megabytes).


Resize Left Boundary Larger {Max|Min|Value}

Resize a NetWare or extended partition larger by specifying the change 
in position of the left boundary. This operation is for NetWare and 
extended partitions only.

Max - Moves the boundary of a NetWare or extended partition as far 
to the left as possible (flush with the next partition or the 
beginning of the drive).

Min - Moves the boundary of a NetWare or extended partition to the 
left, the minimum amount possible (1 cylinder).

Value - Moves the boundary of a NetWare or extended partition left 
by the amount of the value specified (in megabytes).


Resize Left Boundary Smaller {Max|Min|Value}

Resize an extended partition smaller by specifying the change in 
position of the left boundary. This operation is for NetWare and 
extended partitions only.

Max - Moves the left boundary of a NetWare or extended partition as 
far to the right as possible (flush with the first logical partition).

Min - Moves the left boundary of a NetWare or extended partition to the 
right, the minimum amount possible (1 cylinder).

Value - Moves the left boundary of a NetWare or extended partition 
right by the amount of the value specified (in megabytes).


Resize Smaller {Max|Min|Value}[/Clustersize={512|1|2|4|8|16|32}]

This command reduces the size of a partition by specifying the 
incremental change in size.

Max - Reduces the partition to the smallest possible size, that is,
removes virtually all unused space from the partition and returns it 
to free space.

Min - Resizes the minimum possible (subtracts one cylinder of data).

Value - Decreases the partition by the value specified (in megabytes).

/Clustersize= - Sets the cluster size for a FAT partition. If omitted, 
ServerMagic uses the smallest possible cluster size. Values include 512 
(bytes) and 1, 2, 4, 8, 16, and 32 (kilobytes).


Resize Space After {Max|Min|Value}[/Clustersize={512|1|2|4|8|16|32}

This command resizes an extended partition by specifying the amount of 
free space after the partition following the resize. 

Max - Resizes the right boundary of the partition to leave the most 
possible space after the partition, that is, reduces the boundary to 
the rightmost logical partition.

Min - Resizes the right boundary of the partition to leave the minimum 
possible space following it, that is, flush with the next primary 
partition or the end of the hard disk.

Value - Resizes the right boundary of the partition to leave the 
amount of space specified (in megabytes).

/Clustersize= - Sets the cluster size for a FAT partition. If omitted, 
ServerMagic uses the smallest possible cluster size. Values include 512 
(bytes) and 1, 2, 4, 8, 16, and 32 (kilobytes).


Resize Space Before {Max|Min|Value}

Resize an extended partition by specifying the amount of free space 
before the partition after the resize is completed. 

Max - Resizes the left boundary of a NetWare or extended partition 
so that the space before is as large as possible, that is, moves the 
boundary to the beginning of the first logical partition.

Min - Resizes the left boundary of a NetWare or extended partition to 
eliminate space preceding the extended partition, that is, flush with 
the preceding primary partition or the beginning of the hard disk.

Value - Resizes a NetWare or extended partition to leave the amount 
of space specified (in megabytes).


Select Copy Drive {Num}

This command selects the drive that is the target of a copy command.

Num - Number of the drive to select starting at 1.


Select Copy Partition {DriveLetter|"Label"|Next|Previous|Num}

This command selects the partition or free space on the copy drive 
that is the target of a copy command.

DriveLetter - Selects the partition by drive letter.

"Label" - Selects the partition by label.

Next - Selects the partition that is numerically one higher than the 
previously selected partition; cannot be the first select copy 
partition statement in the script file.

Previous - Selects the partition that is numerically one lower than 
the previously selected partition; cannot be the first select copy 
partition statement in the script file.

Num - Selects the partition by partition number.


Select Drive {Num}

This command selects the physical drive. 

Num - Number of the drive to select starting at 1.


Select Move Drive {Num}

This command selects the hard disk that is the target of a Move 
NetWare Partition to Another Disk command.

Num - Number of the drive to select starting at 1.


Select Move Partition {Num|Next|Previous}

This command selects the target free space partition on the hard disk 
that is the target of a Move NetWare Partition to Another Disk command.
Refer to "Unhide" on page 15 for additional information.

Num - Number of the free space partition on the selected move drive.

Next - Selects the partition that is numerically one higher than the 
previously selected move partition; cannot be the last select move 
partition statement in the script file.

Previous - Selects the partition that is numerically one lower than 
the previously selected move partition; cannot be the first select 
move partition statement in the script file.


Select Partition {DriveLetter|"Label"|Extended|Next|Previous|Num}

This command designates which partition on the selected drive is the 
current partition. You can identify partitions in a number of ways. 
It is usually best to use a method that positively identifies a 
partition, such as the drive letter or label assigned to a partition. 
Since this is not always possible, you can also select a partition by 
its number or its relationship to a known partition. 

IMPORTANT!	Use caution when selecting a partition by its number, since 
partition numbers can change as a script executes. It is often 
preferable to use Select Partition Next or Select Partition Previous to 
select unlabeled partitions. However, you must select free space and 
partitions without drive letters or labels by number. If you question 
which partition will be selected after an operation, you can use the 
normal version of the program (without scripting) and perform the same 
operation on a test machine and observe which partition is selected 
after the operation. You can also use the Show Partitions command to 
show the current status of partitions.

DriveLetter - Selects the partition by drive letter.

"Label" - Selects the partition by label. The label must be in quotes.

Extended - Selects the extended partition on the drive.

Next - Selects the partition that is numerically one higher than the 
previously selected partition; cannot be the first select partition 
statement in the script file.

Previous - Selects the partition that is numerically one lower than the 
previously selected partition; cannot be the first select partition 
statement in the script file.

Num - Selects the partition by partition number.


Set Active

This command marks the selected primary partition as the active, or 
bootable, partition.


Show Copy Partitions

This command displays the copy partitions on the currently selected 
drive. This command must be preceded by Select Drive, Select 
Partition, and Select Copy Drive.


Show Partitions

This command displays the partitions on the currently selected copy 
drive, much like the PowerQuest PARTINFO utility program.


Show Preferences

This command shows the current ServerMagic preferences.


Unhide

This command unhides the currently selected partition. See also "Hide."



5. Script Suggestions and Notes

PowerQuest recommends that you check each partition before you modify 
it. A script file terminates as soon as an error occurs, so it is best 
to find errors before a script makes any changes to partitions.

Since partitions must start on cylinder boundaries, ServerMagic may 
modify a specified number to fit the geometry of the hard disk. 
ServerMagic allows a margin of error of 1 cylinder above or below the 
size specified in a statement. For example, on a hard disk with 0.5-MB 
cylinders, a statement to resize a partition to 10 MB is successful as 
long as ServerMagic can resize the partition to at least 9.5 MB.

Under normal operation, if a script determines that it will not be able 
to reboot the machine after making the changes specified in a script, 
the script will terminate with an error. One situation where this is 
known to happen is under OS/2 if the DOS.SYS file is not in the 
CONFIG.SYS (such as when you boot from utility diskettes). You should 
use the ALLOW MANUAL REBOOT script statement at the beginning of the 
script if it is not a problem to reboot from the keyboard.

	Selecting Drives and Partitions

	Virtually all commands perform actions on specific partitions. 
	Before ServerMagic can execute a command from a script file, 
	you must have defined the partition that the command affects. A 
	few commands affect more than one partition. For example, the 
	copy command moves a defined partition to a defined free space. 
	For these commands, you must define all partitions affected by 
	the command before ServerMagic can execute the command.

	When most commands are executed, the partition affected by the 
	command is still selected afterward. For example, Resize and Move 
	leave the partition operated on as the selected partition. Create 
	leaves the partition created as the selected partition. Delete 
	leaves the free space created by deleting the partition as the 
	selected partition.



6. Sample Scripts

Resizing a NetWare Partition

You have a 4 GB drive that contains a 50 MB, primary DOS partition. The 
hard disk also has a 2 GB NetWare partition. You need to increase the 
NetWare partition to 3 GB. 

//Select drive and NetWare partition, then Enlarge the 
//selected partition
Select Drive 1
Select Partition 2
Resize 3000


Moving a NetWare Partition to Another Disk

Your NetWare partition is on a 2 GB hard disk, and you want to move 
the DOS and NetWare partitions to a new 4 GB drive. 

//Select the source drive and partition of the DOS partition
Select Drive 1
Select Partition 1
//Select the copy destination for the DOS partition on the new disk
Select Copy Drive 2
Select Copy Partition 1
//Copy the DOS partition
Copy
//Select the NetWare source drive and partition
Select Drive 1
Select Partition 2
//Select the NetWare source drive and partition
Select Move Drive 2
Select Move Partition 2
//Perform the actual move
Move NetWare Partition to Another Disk