Starting a Win32 program

The /usr/contrib/win32/bin directory includes shell script wrappers for common Windows command-line utilities, such as net, cacls, and netstat. Because this directory is automatically placed into your PATH when you start an Interix shell, you can run these Windows utilities by typing their name at the shell prompt. For example, to run the Windows calculator in the Korn shell, type calc at the dollar sign ($) prompt.

When running other Win32 programs from an Interix shell, the name of the program must be in POSIX format. For example:

/dev/fs/C/WINNT/poledit.exe

Case is also important. In the preceding example, the executable file is stored on the disk as poledit.exe. If you typed it in uppercase, it will not work. You must also include the file extension.

If the path to the program includes spaces, you can enclose the entire command and path with double quotation marks ( "). For example, the following command will open Microsoft Word:

"/dev/fs/C/Program Files/Microsoft Office/Office/WINWORD.EXE"

When you add an argument to a Win32 program, the argument must be in Win32 format and enclosed by single quotation marks ('), such as:

/dev/fs/C/WINNT/system32/notepad.exe 'C:\text\memo.txt'

In this example, the file memo.txt is automatically opened in Notepad. You can leave off the single quotation marks if you type two back slashes (\\)where you would normally type one back slash (\). This is illustrated in the following example:

/dev/fs/C/WINNT/system32/notepad.exe C:\\text\\memo.txt

The double back slashes (\\) are necessary because the UNIX systems treat single back slashes (\) in a special way.

You can use the ampersand (&) metacharacter to run Win32 programs in the background. Many Win32 programs do not return control to your terminal until after the program has exited. You can solve this problem by running the program in the background. For example:

/dev/fs/C/WINNT/system32/notepad.exe C:\\text\\memo.txt &

Adding directories to your PATH

The PATH environment variable contains a list of directories that are searched when looking for a command to execute. For example, poledit.exe is typically found in the WINNT directory on the C: drive. If you want to run poledit.exe without having to type the entire path, you can add /dev/fs/C/WINNT to your Interix PATH by typing the following command at the Interix prompt or into the .profile file. The path name must be in POSIX format, not Win32.

export PATH="$PATH:/C/WINNT"

The PATH environment variable is the primary mechanism used for searching and finding commands. If the user types a command that does not contain a slash (/), the command is searched in all the directories specified in PATH. If the user types a command that does contain a slash (/), PATH is not used.

Examining PATH_WINDOWS

The Interix profile file sets the PATH_WINDOWS environment variable in which you can specify a suffix matching order. This is used to look for Windows commands with standard extensions, namely .com, .exe, .ksh, .bat, and .cmd. In the Interix Korn shell, if you type the echo $PATH_WINDOWS command, you will see the default value of PATH_WINDOWS set to the following (or something similar):

/dev/fs/C/WINDOWS/system32/.com,.exe,.ksh,.bat,.cmd,:/dev/fs/C/SFU/common/.com,.exe,.ksh,.bat,.cmd,

The path name is in POSIX format, not Win32.

You can also specify your own suffix matching order. The value of PATH_WINDOWS is a colon-separated list of directory names with the following format:

pathname[/suffix-list][:pathname[/suffix-list]]

The suffix-list is a comma-separated list of suffixes. Each suffix starts with a period (.) and contains up to a total of three additional characters, as illustrated in this example:

PATH_WINDOWS=/dev/fs/D/SFU/common/.exe,.ksh:/dev/fs/C/WINNT/system32/.exe,.bat

In this example, .exe and .ksh files will be suffix matched in the /dev/fs/D/SFU/common directory, and .exe and .bat files in the /dev/fs/C/WINNT/system32 directory. A file with the .exe extension will be matched in the /dev/fs/C/WINNT/system32 directory only if it is not found in the /dev/fs/D/SFU/common directory.

If you specify only the directory, such as PATH_WINDOWS=/dev/fs/C/WINNT/system32 all the suffixes are matched in the following order:

The last example in the list is empty. This indicates the lack of a suffix. For example, you can enter the following at an Interix shell prompt:

PATH_WINDOWS=/dev/fs/C/WINNT/system32:/dev/fs/D/sfu/common/.exe
echo $PATH_WINDOWS

The echo $PATH_WINDOWS command displays:

/dev/fs/C/WINNT/system32/.com,.exe,.ksh,.bat,.cmd,:/dev/fs/D/SFU/common/.exe

Note that the empty field between .cmd and : indicates that there is a "no suffix" entry in the search path.