Command Files

You can enter Stat/Transfer commands in a command file, as well as interactively at the Stat/Transfer prompt or the operating system prompt.


When you enter commands at the prompt, the command is executed immediately. When you store commands in a file, the commands are executed when you execute the file.


You can execute command files from the Stat/Transfer prompt or from the operating system prompt.


When you wish to run batch jobs, you must use command files.


Constructing Command Files

You can create Stat/Transfer command files as ASCII documents.  Type commands in the document just as you would type them at the Stat/Transfer prompt.


You can put comments in command files by preceding the comments with a double slash, '//'.


Command File Name Extensions

Stat/Transfer assumes that command files have the extension .stcmd (Stat/Transfer Command).


The old extension .stc, which conflicts with the extension used by SAS for CPORT libraries, is still supported, but is now deprecated.


If you are executing a command file from the Stat/Transfer command line, you need not give an extension unless the file does not have the extension .stcmd.


If you wish to run a command file from the operating system command line, it must have the extension .stcmd and the extension must be given.


Executing Command Files

Executing Command Files from the Stat/Transfer Prompt

You can execute a command file at the Stat/Transfer prompt by typing:


      EX commandfilename


If you enter commandfilename without an extension, an extension of .stcmd is assumed by Stat/Transfer.


A command file named weekly.stcmd could be executed by typing


     ex weekly



Executing Command Files from the Operating System Prompt

You can execute a command file at the operating system prompt by typing


        ST    commandfilename.stcmd


In order to use command files from the operating system prompt, you will need to be in the directory in which you installed Stat/Transfer, or have a path defined to it or give the path explicitly.


For example, a command file, repeat.stcmd, will be executed if, at the operating system prompt, you type:


     st   repeat.stcmd


Note that the extension, which is explicitly given, must be .stcmd.  If the file is not in the Stat/Transfer program directory, the complete path to it must be given.


If you do the same transfers all of the time, the ability to execute command files in this way allows you to set up a shortcut that will perform your transfers with a single click on a desktop icon.



Running and Editing Command Files from the Windows Explorer

When you double click on a Stat/Transfer command file in the Windows Explorer, the command processor will be launched and the command file executed.


If the last command in the file is 'quit', you will be taken directly back to the Explorer.  Otherwise, the command 'quit' at the command line will return you to the Explorer


You can edit a command file by right-clicking then selecting 'edit'.



Running Programs and Commands in Command Files

Command files can contain commands to execute programs, as well as Stat/Transfer commands.


These options will, for example, allow you to zip or unzip files with commands given to the Stat/Transfer command processor.  For example, a command file might contain the following set of commands.


// unzip a SAS file

!pkunzip  mysas1.sd2


// copy it to an SPSS file

copy  mysas1.sd2  myspss1.sav


// zip your new SPSS file

!pkzip  myspss1.sav


// delete the SPSS file

!del myspss1.sav


// delete the SAS file

!del mysas1.sd2


where '//' indicates to the command processor that what follows is a comment and '!' has been used instead of 'dos'.


A sequence of command such as these can be entered directly at the Stat/Transfer command prompt or stored in a command file for batch execution.