[vox-tech] Identifying the directory that contains the currently running executable?

Ken Bloom kabloom at ucdavis.edu
Fri Aug 27 10:28:27 PDT 2004


Is there a way to identify the directory that contains the currently
running executable, so that I can programmatically refer to it?
i.e. if I am running /usr/bin/myprog, but pwd is /home/bloom, how can
I programmatically get either the pathname '/usr/bin' or
'/usr/bin/myprog'. (This question asks about a C program).

Is there a way to identify the directory that contains the currently
running script in bash? i.e. if I'm running /home/bloom/bin/foo in
/bin/bash, and pwd is /home/bloom, how can I programmatically get
either /home/bloom/bin/foo or /home/bloom/bin to refer to it?
(This would be particularly nice when using calling `java -classpath`
from a shell script wrapper)

Are there ways to do this in other scripting languages (e.g. perl)?

-- 
I usually have a GPG digital signature included as an attachment.
See http://www.gnupg.org/ for info about these digital signatures.
My key was last signed 08/18/2004. If you use GPG *please* see me about 
signing the key. ***** My computer can't give you viruses by email. ***
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://ns1.livepenguin.com/pipermail/vox-tech/attachments/20040827/79a2c832/attachment.bin


More information about the vox-tech mailing list