problem with whence

i have a shell script(report.ksh) where i am supposed to redirect the output of whence to a log file.

but when i am doing so im gettin an error

whence: command not found

when i execute the same command on the command prompt i am gettin the output.

can anyone tell me how to do....

thanks and regards

Are you sure that the script is interpreted by ksh? Does the first line contain "#!/bin/ksh"?

ya...

Telling us what OS you are running on can help you know...

man page:
Man Page for whence (OpenSolaris Section 1) - The UNIX and Linux Forums

As you can see its builtin the shell in most modern unix, when present: DG/UX has no, some linux also...

Linux.....

A Mandrake?

Im not certain it is not a ksh builtin function, check you are using ksh shell

the thing is its working when i use it on the cmd prompt...but i use it in a shell script im gettin the error....

That means your script has not the same environment as you have in interactive mode, try to source your .profile at the beginning of your script

#!/bin/ksh

#your comments...

. $HOME/.profile

# the rest of your script...

echo $SHELL .. will let u know which shell u r using , if it is not ksh, will give u a command not found

@vbe

im doing the same..sourcing the file..still i get the error...

can you write full whence command that you use

whence ls > ${loc}/log.out

What do you get when you type:

echo $0

Do the same in the script

./report.ksh is the output........

And on command line echo $0 gives you what?

i get "-ksh"

---------- Post updated at 10:02 AM ---------- Previous update was at 09:47 AM ----------

sorry i found the solution...but raising new errors....i left a space before the #! at the top.....the new error is some cmds only work in bash shell can u tell me how to over come this situation can i use a #! /bin/bash in the middle of a script....

can you try only this

 
whence ls

Try in debug mode
first line of your script:

#!/bin/ksh -x

---------- Post updated at 17:09 ---------- Previous update was at 17:06 ----------

Arrgh - out of phase (timewise...)

Ok lets pick up at your last post:
I would start by testing if whence works in bash...

Hi.

whence is a ksh build-in alias (and won't (i.e. probably wouldn't, shouldn't, couldn't!) work in bash).

There's no reason why it shouldn't work in a script if the script is actually running in ksh. Assuming the alias wasn't unset.

@vbe...

#!/bin/ksh -x

is working...thnq so much...