Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh 'command' doesn't work on OpenServer?

Status
Not open for further replies.
Jun 22, 2000
6,317
0
0
AU
I can't figure out why the command ksh built-in doesn't work on an SCO OpenServer 5.0.5 system:

[tt]$ alias echo="echo hi"
$ echo bye
hi bye
$ command echo bye
ksh: command: not found
$ whence -v command
command is an exported alias for command
$ alias
autoload='typeset -fu'
command='command '
dir='ls -lF'
echo='echo hi'
functions='typeset -f'
grep=/bin/grep
history='fc -l'
integer='typeset -i'
local=typeset
ls='ls -l'
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'
type='whence -v'
$ unalias command
$ command echo bye
ksh: command: not found
$ ps -fp $$
UID PID PPID C STIME TTY TIME CMD
me 16368 16366 2 12:27:14 ttyp2 00:00:00 -ksh
$
[/tt]

It's mentioned on the ksh(C) and command(C) man pages?

Annihilannic.
 
could be ksh-93 vs ksh-88 issue. i tried on UW 7.11 which has ksh93 by defalut as ksh and ksh88 for compatibilty. I get same error on ksh88 but not on default ksh.

Thansk to members like u and this forum, i do learn many things. i had not heard or read about this command before.

However, even after reading it i am still not very clear about its usage i.e when, where and why to use it

regds
[pipe]
sys_fact
 
Thanks for checking that. It's kind of ridiculous that they list it on the man page though if it's not supported by the insalled version of ksh. :)

It's useful for overriding a function and forcing the shell to execute the "real" command. For example, I have a function called ssh which does a regexp search through my known_hosts file for matching hostnames, and if there are multiple matches prompts to choose which I want to connect to. But to run the actual ssh command from within that function obviously I don't want it to recursively call the function, so I use command ssh hostname.

Hmm... while coming up with an example for you I've learned something new... it only applies to functions, not aliases, so here goes:

[tt]$ function ls {
> command ls -l "$@"
> }
$ ls
total 0
-rw-r--r-- 1 me other 0 Nov 25 10:34 file1
-rw-r--r-- 1 me other 0 Nov 25 10:34 file2
-rw-r--r-- 1 me other 0 Nov 25 10:34 file3
$ command ls
file1 file2 file3
$[/tt]

Another frustrating difference between different Ksh's and different platforms is the varying results you get from which, whence and type. :-( If anyone can recommend the most portable and reliable of these methods to identify the location of a binary in your PATH (apart from a manual search) I'd be glad to hear it.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top