On 10/1/07, Eric Iverson <[EMAIL PROTECTED]> wrote:
> Right now I am stumped. Is there a way in UNIX to know the full path to the
> program that is running? Is there an easy way (C library call, not use of a
> proram like which which can be aliased and otherwise messed with) to find
> the full path to a name that is on PATH?

I took a look at this:

First, note that you have this problem even without symlinks.  If I
have the j602 directory in my path, jconsole fails.

Second, note that boxed display defaults to a non-meaningful
behavior for jconsole running on an arbitrary linux box.  To make
this correspond to what is documented at
http://www.jsoftware.com/help/dictionary/dx009.htm
I used the workaround:
   9!:7'+++++++++|-'

To find the directory containing jconsole, ignoring the symlink
issue, I would probably use something like this:

GETENV=: 2!:5
PATH=:<;._1':',GETENV'PATH'
FEXIST=: (1: 1!:4) ::0:"0

mydir=:3 :0
  a0=:0{::ARGV
  p=: PATH
  if.'/'e.a0 do.p=:'.';p end.
  f=:{. (#~ FEXIST) p,&.><'/',a0
  }.;}:<;.1'/',>f
)

To address the symbolic link issue, I would probably use something
like:

dirname=: [: }.@;@}: '/' <;.1@, ]
readlink=: (((('/' ~: [EMAIL PROTECTED]) # '/',[EMAIL PROTECTED]) , ]) 2!:0 @ 
('readlink '
, ])) ::] ^:_

(watch out for line wrap)

I would process f through readlink before finding its directory.

But when I tested this, I was getting intermediate results displayed
to the console when following symbolic links.  I think this is a
j602 beta bug

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to