Scripting and Automation

One of the main strengths of PTC MKS Toolkit is its ability to create scripts that can be easily modified and updated. Such scripts make it easy to repeat tasks that need to be performed multiple times. When combined with the PTC MKS Toolkit scheduling utilities, it becomes simple to create complex tasks that are repeated at scheduled times and intervals, such as builds or nightly back-ups.


The PTC MKS KornShell, PTC MKS C Shell, and PTC MKS Bourne-Again Shell contain similar sets of built-in commands that can be combined with other PTC MKS Toolkit utilities to form shell scripts. Shell scripts are designed to be easily run from the command line. In addition to the normal command line scripting available in these shells, the MKS KornShell also contains several commands that allow you to create graphical shell scripts, that is, scripts that take advantage of Windows’ graphical capabilities, such as dialog boxes, drop down lists, check boxes, and so on. PTC MKS Toolkit also includes tclsh, the Tcl shell (see “Tcl” below) and pdksh is included on the PTC MKS Toolkit CD as a sample.


The awk scripting language is designed primarily for manipulating text files, especially for extracting information and presenting it in a given format. awk is ideally suited for manipulating text files that contain information in an organized format, such as text database. awk differs from many scripting languages in that it automatically loops through the files provided as input line-by-line and breaks each line into fields. Actions are normally defined to take place when certain conditions are met (for example, a line contains a string matching a regular expression or a specific line number in the file is reached). It is not unusual for awk scripts to be called from shell scripts, especially when creating the equivalent of command-line utilities. The outer shell script processes the command line arguments and passes the necessary information to the awk script. The cgrep utility in the PTC MKS Toolkit Resource Kit is an example of this.


Perl is an eclectic but popular scripting language that borrows syntaxes and commands from the C programming language, awk, sed, shell scripting languages, and many other places. Perl’s wide range of commands and functions and the ability to add extensions make it ideal for tasks such as quick prototyping, system utilities, software tools, system management tasks, database access, networking, and Web programming. For example, the COM module provided in the PTC MKS Toolkit version, lets Perl communicate with Windows COM objects.


Tcl (Tool Command Language) is a very simple scripting language that is easily extensible, has a consistent command syntax, and features a wide range of commands. It is highly portable and is ideally suited as an integration tool, that is, a tool that is used by one application to communicate with another. In truth, Tcl is actually both a scripting language that can be run from the Tcl shell (tclsh) and a library of routines, the Tcl development APIs, that can be embedded in C applications. The ability to embed Tcl in C applications allows Tcl to serve as the command language for the C application. tclsh and the scripting language are available in all PTC MKS Toolkit products, while the embeddable library is only available with the PTC MKS Toolkit migration products.

Scheduling Utilities

The PTC MKS Toolkit Scheduling Suite includes command-line utilities and the graphical PTC MKS Toolkit Scheduler that serve as interfaces to the Windows Task Scheduler. Using these interfaces provides greater feedback and flexibility than is available with the Windows Task Scheduler:

  • The at command-line utility schedules a task to run at a specified time.
  • The batch command-line utility schedules a task to run immediately.
  • The crontab command-line utility lets you create, edit, and view a text file that contains the scheduling information for one or more tasks.
  • The taskrun command-line utility schedules a task to run at a specified time and sends the output and errors produced by the task to a specified location. Thiscommand is primarily intended for use by the at, batch, and crontab utilities although it can also be used directly.
  • The wts command-line utility is similar to the at utility, but allows you to schedule a task to run on a remote machine and to remove or edit an existing task.

The PTC MKS Toolkit Scheduler graphical utility (tksched) allows you to schedule tasks using a graphical interface that features greater scheduling feedback and flexibility than the Windows Task Scheduler.


The mksrv command-line utility lets you run any program or script as a service. Once set up as a service, the program or script can be run automatically on system start-up and can be stopped and restarted like any other service.