TOC PREV NEXT INDEX

Put your logo here!


22 OS Support Routines


The routines in this category provide generic operating system support

22.1 SYSTEM Function

The os.system function executes a single program and waits for the execution of that command before returning. Here is the syntax for the os.system call:

os.system( "system command" );
 

The string you pass as the single parameter roughly corresponds to a command shell command (e.g., the Windows command line prompt or the Linux Shell prompt). This consists of the program name followed by any command line parameters, separated by spaces.

The first thing to note about this function is that the results are system-specific. Although this function is available in all operating systems that the HLA Standard Library supports, the semantics of the commands you pass to this function vary by operating system. Therefore, programs that call this function will not usually be portable between operating systems.

Special notes for Windows users: the os.system function does not directly allow the execution of intrinsic (built-in) cmd.exe commands. If you want to execute a command like DIR, CD, MD, etc., that aren't actual programs, but simply commands that cmd.exe executes directly, you have to run an instance of the command interpreter to pull this off, e.g.,

	os.system( "cmd /C dir" );  // Executes 'DOS' directory command
 

 

Please see the description of the Windows "cmd.exe" program for more details (type "help cmd" at the command line prompt). Also note that Windows will use the current PATH environment variable to locate the executable program, if it is not in the current subdirectory.

Special notes for Linux users: If the program name appearing at the beginning of the string does not specify the path to a file that Linux can find, Linux will prefix the name with "/bin/" and then "/usr/bin/" in an attempt to locate the file.

The function fails silently if it cannot find or execute the specified program.



TOC PREV NEXT INDEX