Executing KornShell script

CuriousGuy picture CuriousGuy · May 24, 2013 · Viewed 63.3k times · Source

I can't execute my KornShell (ksh) script without the ksh command. I included #!/bin/ksh in the first line of the script but when I try to execute it by name only, it says no such file or directory. Can someone help me?

Answer

tarrsalah picture tarrsalah · May 24, 2013
  • make sure that ksh is correctly installed in /bin/ksh

    try which ksh from the command-line.

    consider #! /usr/bin/env ksh for more portability.

  • for executing a script run from the command-line ./script in the directory where script exist.

  • If you want to execut the script from any directory without ./ prefix, you have to add the path to your script to the PATH environment variable, add this line

    export PATH="path_to_your_script":$PATH

    to you ~/.kshrc file.