Shell script not executing

executablekshshell

Not sure what is happening.

Lets call script a.sh with the following

/users/guru$ cat a.sh
#! /usr/bin/ksh

echo "Hello"
date

Execute with ksh. It gets done.

/users/guru$ ksh a.sh
Hello
Tue Jul 15 15:00:52 EDT 2014

Ensure file permission and ksh path.

/users/guru$ ls -l a.sh
-rwxrwxrwx    1 guru  kpc         35 Jul 15 15:00 a.sh
/users/guru$ a.sh
ksh: a.sh:  not found
/users/guru$ which ksh
/usr/bin/ksh

Best Answer

Try "./a.sh" when trying to execute it. It needs to know where the file is at.

The './' tells it to look in the current directory.

Related Question