PTC MKS Toolkit Knowledge Base

Section:IO
Product:MKS Toolkit (All)
Version:
OS:All
Keywords:PATHEXT, SHPATHEXT, file extension
Category:Utilities/Knowledge Base


Why can't the MKS KornShell find my scripts unless I type the extension?


If you enter a filename without an extension, the MKS KornShell will look for the file with one of the following extensions (by default):

  • .exe
  • .ksh
  • .com
  • .bat (Win9x/Me) or .cmd (other Windows systems)
  • no extension

To allow you to change this list, the PATHEXT environment variable was added to Toolkit 6.1. If set, its value will replace the default list above. By default PATHEXT is unset. However, if you start your MKS KornShell from a Windows command line (command.com and cmd.exe) PATHEXT will be set. It will not include .ksh or no extension entries. This behavior can be avoided by setting PATHEXT manually in your environ.ksh, or by using any MKS KornShell after build 209 (i.e. a current version of the MKS Toolkit). In these newer shells, if PATHEXT is set, .ksh and no extension are always added to its list. This happens internally so you won't see them if you display PATHEXT.

Current versions of the MKS KornShell have an environment variable, SHPATHEXT, which supercedes PATHEXT. If it is set, PATHEXT is ignored. You should use this variable if you want to customize the list of extensions searched for. Here is how to set SHPATHEXT to maintain the pre-6.1 default behaviour and add the perl and an alternate shell script extension:

    export SHPATHEXT='.exe;.com;.bat;.cmd;.ksh;;.pl;.sh'