Re: portable way of locating an executable (like which)

2012-09-22 Thread Ramchandra Apte
On Friday, 21 September 2012 02:37:01 UTC+5:30, gelonida wrote: > I'd like to implement the equivalent functionality of the unix command > > /usr/bin/which > > > > The function should work under Linux and under windows. > > > > Did anybody already implement such a function. > > If not, is

Re: portable way of locating an executable (like which)

2012-09-21 Thread Hans Mulder
On 21/09/12 04:31:17, Dave Angel wrote: > On 09/20/2012 06:04 PM, Jason Swails wrote: >> On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N wrote: >> >>> I'd like to implement the equivalent functionality of the unix command >>> /usr/bin/which >>> >>> The function should work under Linux and under window

Re: portable way of locating an executable (like which)

2012-09-21 Thread Tarek Ziadé
On 9/21/12 1:59 AM, Nobody wrote: On Thu, 20 Sep 2012 23:06:46 +0200, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Note that "which" attempts to emulate the behaviour of execvp()

Re: portable way of locating an executable (like which)

2012-09-20 Thread Andrew Berg
On 2012.09.20 21:31, Dave Angel wrote: > I don't have a Windows machine set up right now, but I believe there are > two more directories to search, besides the ones described in the PATH > variable. > > One is the current directory, and the other is the Windows directory > (maybe also the xxx/syst

Re: portable way of locating an executable (like which)

2012-09-20 Thread Dave Angel
On 09/20/2012 06:04 PM, Jason Swails wrote: > On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N wrote: > >> I'd like to implement the equivalent functionality of the unix command >> /usr/bin/which >> >> The function should work under Linux and under windows. >> >> Did anybody already implement such a fu

Re: portable way of locating an executable (like which)

2012-09-20 Thread Nobody
On Thu, 20 Sep 2012 23:06:46 +0200, Gelonida N wrote: > I'd like to implement the equivalent functionality of the unix command > /usr/bin/which > > The function should work under Linux and under windows. Note that "which" attempts to emulate the behaviour of execvp() etc. The exec(3) manpage wil

Re: portable way of locating an executable (like which)

2012-09-20 Thread Mark Lawrence
On 21/09/2012 00:15, Gelonida N wrote: On 09/21/2012 12:04 AM, Jason Swails wrote: Thanks a lot Jason, I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split

Re: portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
On 09/21/2012 12:04 AM, Jason Swails wrote: Thanks a lot Jason, I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe

Re: portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
On 09/21/2012 12:21 AM, Chris Angelico wrote: On Fri, Sep 21, 2012 at 7:47 AM, Mark Lawrence wrote: On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybod

Re: portable way of locating an executable (like which)

2012-09-20 Thread Chris Angelico
On Fri, Sep 21, 2012 at 8:32 AM, Ian Kelly wrote: > On Thu, Sep 20, 2012 at 4:21 PM, Chris Angelico wrote: >> os.sep is the directory separator, but os.pathsep may be what you >> want. Between that and os.getenv('path') you can at least get the >> directories. Then on Windows, you also need to ch

Re: portable way of locating an executable (like which)

2012-09-20 Thread Ian Kelly
On Thu, Sep 20, 2012 at 4:21 PM, Chris Angelico wrote: > os.sep is the directory separator, but os.pathsep may be what you > want. Between that and os.getenv('path') you can at least get the > directories. Then on Windows, you also need to check out > os.getenv('pathext') and split _that_ on the s

Re: portable way of locating an executable (like which)

2012-09-20 Thread Chris Angelico
On Fri, Sep 21, 2012 at 7:47 AM, Mark Lawrence wrote: > On 20/09/2012 22:06, Gelonida N wrote: >> >> I'd like to implement the equivalent functionality of the unix command >> /usr/bin/which >> >> The function should work under Linux and under windows. >> >> Did anybody already implement such a fun

Re: portable way of locating an executable (like which)

2012-09-20 Thread Jason Swails
On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N wrote: > I'd like to implement the equivalent functionality of the unix command > /usr/bin/which > > The function should work under Linux and under windows. > > Did anybody already implement such a function. > If not, is there a portable way of splittin

Re: portable way of locating an executable (like which)

2012-09-20 Thread Mark Lawrence
On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. Searching found nothing obvious to me :( If not, is there a por

portable way of locating an executable (like which)

2012-09-20 Thread Gelonida N
I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. If not, is there a portable way of splitting the environment variable PATH? Thanks for any sugestions --