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

2004-08-27 Thread Peter Jay Salzman
On Fri 27 Aug 04, 11:21 AM, ME <[EMAIL PROTECTED]> said: > Ken Bloom said: > > I guess that solves the C program problem, because I can use getpid() > > to fill in the blank, and readlink(2) to find the elf executable. > > > > That is one wierd symlink. ME wrote in May > > (http://www.lugod.org/mai

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

2004-08-27 Thread Ken Herron
--On Friday, August 27, 2004 11:36:50 AM -0700 Bill Kendrick <[EMAIL PROTECTED]> wrote: The program can examine argv[0], but that may contain only the program name without the directory path, in which case you would generally read the PATH environment variable and look for the program in each dir

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

2004-08-27 Thread Ken Bloom
On Fri, Aug 27, 2004 at 11:04:42AM -0700, Matt Roper wrote: > On Fri, Aug 27, 2004 at 10:28:27AM -0700, Ken Bloom wrote: > ... > > 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 /h

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

2004-08-27 Thread Bill Kendrick
On Fri, Aug 27, 2004 at 11:31:34AM -0700, Ken Herron wrote: > Bill noted the entry in the /proc filesystem. For systems without /proc > there's no simple way to get this. Yeah, I was wondering... ;) > The program can examine argv[0], but > that may contain only the program name without the dir

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

2004-08-27 Thread Ken Herron
--On Friday, August 27, 2004 10:28:27 AM -0700 Ken Bloom <[EMAIL PROTECTED]> wrote: Is there a way to identify the directory that contains the currently running executable, so that I can programmatically refer to it? Bill noted the entry in the /proc filesystem. For systems without /proc there's

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

2004-08-27 Thread ME
Ken Bloom said: > I guess that solves the C program problem, because I can use getpid() > to fill in the blank, and readlink(2) to find the elf executable. > > That is one wierd symlink. ME wrote in May > (http://www.lugod.org/mailinglists/archives/vox-tech/2004-05/msg00247.html) > about deleting t

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

2004-08-27 Thread Matt Roper
On Fri, Aug 27, 2004 at 10:28:27AM -0700, Ken Bloom wrote: ... > 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

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

2004-08-27 Thread Ken Bloom
On Fri, Aug 27, 2004 at 10:30:56AM -0700, Bill Kendrick wrote: > On Fri, Aug 27, 2004 at 10:28:27AM -0700, Ken Bloom wrote: > > 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/

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

2004-08-27 Thread Mitch Patenaude
/proc/$PID/cwd will give the current working directory as a symlink. If you're trying to do this with C/C++, then you can use lstat(2) and readlink(2) to get the information. In a bash script, $0 will give you the argument used to invoke the script. If it was invoked with a full path, then you

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

2004-08-27 Thread Bill Kendrick
On Fri, Aug 27, 2004 at 10:28:27AM -0700, Ken Bloom wrote: > 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

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

2004-08-27 Thread Ken Bloom
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