with in shell script all statements not found

January 21, 2011 at 04:58:30
Specs: Unix
Trying to run a korn shell script I am getting not error for all the staments inside script includeing echo, find , if ,else, echo etc.
how to resolve it ?

See More: with in shell script all statements not found

Report •

January 21, 2011 at 07:59:55
Whatever shell you are running doesn't have the PATH environmental variable set.

If you set set the PATH in your script your do not have to rely on the parent shell.
If you have a system admin, ask them what the PATH should be or if you can get to a normal user's shell, try looking at it:

echo $PATH

Since I don't know what Unix variant you are using, I am just guessing, but you might try:


Report •

January 21, 2011 at 09:57:32
Hey nails,
Thanks for the suggestion. but it did not help though.
even I dont know what variant of Unix is that. but I have very restricted access in the system. and this task of writing the script needs to be completed in a very short time span.

but i have execute permission to all the commands.
I tried eith preceeding all the commands like echo and find with path "/usr/bin/". it did not work though.

i getting not found error for all the constructs also like

if not found
echo not found
else not found
fi not found
echo not found
find not found
ls not found

Report •

January 21, 2011 at 11:34:46
It's PATH - not path. In Unix, environmental variables are capitalized.

It varies, but many Unix commands are in /bin.

When you are at the command line, when you execute:

echo $PATH

is anything returned to you?

If you don't see a valid PATH, try something like this:

export PATH

and see if that helps.

If that doesn't, you better speak to your admin or your instructor.

Report •

Related Solutions

January 21, 2011 at 21:38:39
echo PATH has shown that path is containg/bin and /usr/bin along with other paths in it.
I tried export path also. but problem still persists.

Thanks for help though. :)

Report •

January 22, 2011 at 02:47:14
Your problem is not a PATH one as the commands you mention are built in to the shell. Perhaps you could provide a listing of a program that doesn't work and tell us which shell you are using (you say Korn shell, but is it really ksh rather than sh, csh, or bash?) and which UNIX you are using it on. Then someone can try it on their system.

Report •

January 22, 2011 at 02:50:21
if statements are shell builtins and are not dependent on the PATH variable. The echo statement is an external command so an improper PATH would cause problems.

From a command line, simply type if. You should get a > on the next line. This will work with sh, ksh and bash. It will not work for csh. If you get the > on the next line, then the issue is somewhere in the syntax you are using. If you don't get a > sign, then you have a very strange shell.

A simple script that does not use anything external to the shell.



if [[ $foo == "bar" ]]
print "Foo is equal to bar"
print "Foo is not equal to bar"

If this doesn't work, then I'm at a loss as to what your issue is. Nails pointed out the most obvious cause of what you are experiencing, but "not found" messages generally don't show up when using internal shell commands.

To get your version of Unix, type:

/usr/bin/uname -a

Also, run the ps command with no arguments and see what shell you are in.

Report •

January 22, 2011 at 20:53:53
this is AIX version 5.3 and shell is KSH. I ahve read and execute permission on /bin and/usr/bin .
i am keeping the script in my home folder.
when i type if on command line, i get > in next line also.

i tried the script suggested by you and after replacing [] with test and putting "$foo" i was able to run it.

Report •

January 22, 2011 at 21:20:32
Thank you guys...:).
this was a kind of encoding problem.
initially i prepared a script in text pad (windows environment). then i placed it on unix machine. so it was giving me error because of encoding. although i opened it with vi editor and deleted a few characters . But there was something unrecognized.
now as i am writing the file from scratch in vi editor, then i am able to run.

Report •

Ask Question