Scripting Language

About the Scripting Language

As of version 2.0 of CDEveryWhere there is a scripting language available for those advanced users who want to automate their CD making process. People familiar with writing shell scripts in Unix or batch files in DOS will find the CDEveryWhere scripting language easy to learn. You have as much control of the CD as in the graphical user interface.

Format of a Script

A simple script is shown below:

#
# This is an example script.
# The '#' sign starts a comment.
# The line is ignored when the script is run.
#

# Set the volume name
volname "My CD"

# Add a directory to the root of the CD for all platforms
add     C:\cdroot     all    /

When writing a script, you may have one command per line. Comments begin with a '#' sign. The first word of a command is the command name. All following text are the options to that command. Each option is separated by one or more whitespace characters (space, tab, etc.) Options must be enclosed in double quotes if there are whitespace characters in the option. (See the "volname" command in the above example.).

Running a Script

Once you've written your script you can run it using the following command:

cdew [-quiet] [-verbose] [-show-progress] [-imbed] [-log=<filename>] [-key=[<filename> | "<name>,<org>,<key>"]]-script=<script name> <script options>

WINDOWS USERS - you will need to use the cdewc command to disable the splash screen.

The options in square braces ( [ ] ) are optional. The options to cdew are:

-quiet

Disables all output to the standard out and standard error streams.

-verbose

The verbose option disables the normal progress bar output and outputs detailed information about the progress of the image.

-show-progress

Displays a graphical progress dialog while the image is being written.

-imbed

Progress sent to the standard output stream is formatted suitable for use by processing using another program.

-log

Logs all output to a file. Output is still displayed on the screen. This is not very useful without the -verbose or -imbed option.

-key

Specifies a license key to use. You can specify either a file path to the license key file or name,org,key enclosed by double quotes.

-script

Executes a script. The script name is either a filename or "-", in which case the script is read from standard input. Any parameters following -script are passed as parameters to the script in the variables $1, $2, $3, $4, etc.

Variables

Variables may be used inside the script and are similar in form to Makefile variables. They look like "$(varname)" where "varname" is the name of the variable. For single character variables, the parantheses are not required. Variable may appear anywhere in the script.

Variables are defined using the define command:

define variable_name value

The variable_name may contain any characters except whitespace, the dollar sign or parantheses.

Commands

Following is the complete list of available scripting commands. Most mimic a feature of the graphical interface. Please see the documentation of the graphical feature for how the option affects the CD image.

WINDOWS USERS - If you are a Microsoft Windows user, in the following examples, you must use the double back-slashes "\\" instead of a single forward slash "/" as the directory separators whenver you are refering to the local hard disk.

Commands Descriptions
print <text> Outputs the text to the console.
add <source> <platform> <directory on CD>

Adds content to the image. The first parameter is the source of the content and may be a directory, file or URL using one of the forms below:

ftp://user:password@site:port/directory - Adds an FTP site, user:password is optional
cdew://site:port/directory - Access a CDEveryWhere server. user:password is optional. user is currently ignored.
aufs://directory - Access an Apple/Unix Filesystem at the given directory.
zip://filename - Open a ZIP file. This should be used for AUXZip files.
sfm://directory - Access a Windows NT "Services for Macintosh" volume.
tar://filename - Open a TAR file.

The second parameter specifies the platform, valid parameters are one of: all, iso, joliet, hfs. "iso" includes Unix platforms. The third parameter is the directory on the CD where the directory/files should be located. This should be specified using a forward slash "/" character to separate directories.

remove <platform> <directory on CD> Remove a file, directory, FTP directory or URL from the image that had been previously added. This only works on files, directories, etc. specified in the "add" command. Any files or directories included inside a directory cannot be removed. See the "exclude" command. The platform is one of all, iso, joliet or hfs.
exclude <platform> <pattern> Exclude directories or files based on a pattern. The platform is one of all, iso, joliet or hfs. The pattern is a glob (similar to MS-DOS filename patterns). For example: /dir1/*.txt
include <platform> <pattern> Include directories or files based on a pattern that were previously excluded. The platform is one of all, iso, joliet or hfs. The pattern is a glob (similar to MS-DOS filename patterns). For example: /dir1/*.txt
write [filename] Writes the ISO image of the CD to the file. If no file is specified or the filename is "-" the image is written to standard out. Please note on Windows platforms that Windows uses ASCII streams for standard out, therefore this option is not useful on that platform.
sort <name-ascend | name-descend | date-ascend | date-descend | size-ascend | size-descend> Set the file sort method. This does not affect the sorting of the directory on the CD, only where the file data is placed. Default is size-ascend.
record-date <file|record> Set the date of the files and directories on the CD. Default is the last modified date of the file. Setting "record" will set the date for all files and directories to the date when the CD image is created.
iso <true|false> Enables/disables the ISO9660/RockRidge (i.e. Unix) partition. Default is true.
iso-level <1|2|3> Sets the ISO naming level. Level 1 is the most compatible using the familiar 8.3 format. Level 2 limits filenames to 31 characters. Level 3 limits the filenames to 128 characters. Default is 1.
iso-version <true|false> Sets whether the ";1" ISO version number is appended to the ISO filenames. This does not affect RockRidge capable Unix, Joliet or HFS. Some systems may expect ";1" at the end of filenames and no read the CD if it is not there. Default is true.
iso-strict-naming <true|false> Sets whether the ISO character set is enforced for the ISO partition (excludes Unix, Joliet and HFS). Default is true.
rr-user <number> Sets the user ID number for the Unix partition if not specified by other means (i.e. a local Unix filesystem, FTP, tar, etc.) or the owner preservation setting is false. Default is 0 (root).
rr-group <number> Sets the group ID number for the Unix partition if not specified by other means (i.e. a local Unix filesystem, FTP, tar, etc.) or the owner preservation setting is false. Default is 0.
rr-owner-preserve <true|false> Set if the user/group ownership values should be preserved for the Unix (RockRidge) partition. Default is false.
rr-archive Set optimal setting on the Unix partition for archiving purposes. Preserves user/group settings, permissions and symbolic links.
rr-dist Set optimal setting on the Unix partition for distributing purposes. User and group values are set to 0, permissions are set for everyone read and targets of symbolic links are imported into the CD if the link does not point to a target already added to the CD. This is the default.
rr-link-dups <true|false> Determines if duplicate files on the CD should use a hard or symbolic link. If true, copying the CD to another disk will prevent duplicating files. Does not affect the size of the CD. Default is true.
rr-link-resolve <true|false> Determines if symbolic links off the CD should be imported as hard links. If a link points to a target on the CD, this option does not affect it. The recommended setting is true to prevent broken links on the CD. Default is true.
rr-perm-merge <true|false> Determines if permissions are "merged" across user/group/other. Basically, if any access is read, all become read, if any execute access is enabled, all become executable. Default is true.
joliet <true|false> Enable/disable the Joliet partition. Please note that none of the ISO settings affect Joliet. Filenames will always preserve legal Windows characters up to 64 characters in length. Default is true.
joliet-auto <filename> Set the autorun application for Windows. The filename is relative to the CD root. Setting a filename will create an autorun.inf file on the CD and overwrite any autorun.inf otherwise added to the CD.
rockridge <true|false> Enable/disable the RockRidge (Unix) partition. This must be enabled for most Unix platforms to see long filenames. Default is true.
hfs <true|false> Enable/disable the HFS (Macintosh) partition.
hfs-encoding <text> Set the HFS character encoding. Please see the manual for valid encodings. Examples are MacRoman, MacGreek, etc. If none set, the encoding is chosen to be compatible with the host system's encoding.
hfs-auto <filename> Set the autostart file for Macintosh. The filename must be on the root of the CD and be less than 12 characters.
hfs-type-add <pattern|magic> <value> <creator> <type> Adds a pattern or magic to a creator/type pair.
hfs-type-set <pattern|magic> <value> <creator> <type> Sets the pattern or magic for a creator/type pair. Any previous definitions for the creator/type are removed.
volname <text> Sets the volume name. The volume name will be modified for each platform according to length and character set limitations.
publisher <text> Sets the publisher name.
preparer <text> Sets the preparer name.
application <text> Sets the application description.
copyright <filename> Sets the copyright filename. This setting will not add a file to the CD. This field is not used by most CD drivers.
abstract <filename> Sets the abstract filename. This setting will not add a file to the CD. This field is not used by most CD drivers.
biblio <filename> Sets the bibliography filename. This setting will not add a file to the CD. This field is not used by most CD drivers.
dump Prints out information on the current layout
mkdir <platform> <directory> Create a directory on the CD. The first parameter is the platform, one of all, iso, joliet or hfs. The second parameter is the name of the directory, using forward slash "/" to separate directory names.
define <variable name> <value> Assign a value to a variable. The variable may be used in the rest of the script using the form $(name). For example, the values for variable "x" can be used by putting "$(x)" in the script.

Example Script

#This is a comment

#
# Define variables
#

define	home	/home
define	manual	/projects/CDEveryWhere/manual

#
# Set the volume information
#

volname			"Script Test"
publisher		"My Company"
preparer		"My Company"
application		"CDEveryWhere Script Test"
copyright		copyright.txt
abstract		abstract.txt
biblio			biblio.txt

#
# ISO options. These options never affect the Joliet (Windows),
# HFS (Mac) volume, or RockRidge (Unix).
#

iso			true
iso-level		1
iso-version		true
iso-strict-naming	true

#
# Set RockRidge (Unix) options to distribution mode.
#

rr-dist

#
# Joliet (Windows) options.
#

joliet			true
joliet-auto		""

#
# HFS (Mac) options.
#

hfs			true
hfs-encoding		MacRoman
hfs-auto		""

#
# Set the type/creator information for all files ending in .html.
# The type will be HTML and the creator will be MSIE.
# This is the preferred setting.
# Netscape will open any file with type HTML.
# Internet Explorer will only open files with type HTML and creator MSIE.
# This is the default setting.
#

hfs-type-set		pattern *.html	MSIE	HTML

#
# Set the sorting of the file data on the CD.
# Smaller files will be placed first,
# this will normally improve CD performance.
#

sort	size-ascend

#
# Set the date of the files on the CD. 
# This setting will preserve the modified time of the file.
#

record-date	file

#
# The following "Add" commands add files
# and directories to the CD. Files and directories 
# inside a directory are automatically added to the image.
#

#
# Add a directory from the local hard drive
# (or Windows mapped network drive.)
#

add	$(manual) all /manual

#
# Add a directory from an FTP host. Note this is an anonymous login.
#

add	ftp://myhost.company.com/pub/data all /ftp

#
# Add a directory from a CDEW server.
#

add	"cdew://mac.company.com/BOOTVOLUME/Desktop Folder" all /desktop

#
# Add a directory using the Apple-Unix Filesystem.
#

add	aufs:///AppleUnixFiles all /aufs

#
# Add a MacBinary encoded Mac file.
# The file will be automatically decoded.
#

add	$(home)/MyMacFile.bin hfs /

#
# Create some directories
#

mkdir	hfs /hfs.dir
mkdir	iso /iso.dir
mkdir	all /all.dir

#
# Write the image
# This script takes the first option as the filename for the .iso image.
#

print	"Writing to $1...\n"
write	$1