Re: Find the path of a shell command

2022-10-17 Thread Grant Edwards
On 2022-10-15, Andreas Eder wrote: > On Mi 12 Okt 2022 at 05:00, Paulo da Silva > wrote: > >> The simple question: How do I find the full path of a shell command >> (linux), i.e. how do I obtain the corresponding of, for example, >> "type rm" in command line? >> >> The reason: >> I have python

Re: Find the path of a shell command

2022-10-17 Thread Andreas Eder
On Mi 12 Okt 2022 at 05:00, Paulo da Silva wrote: > The simple question: How do I find the full path of a shell command > (linux), i.e. how do I obtain the corresponding of, for example, > "type rm" in command line? > > The reason: > I have python program that launches a detached rm. It works

Re: Find the path of a shell command [POSTPONED]

2022-10-16 Thread Peter J. Holzer
On 2022-10-16 17:21:03 +0100, Barry wrote: > > On 16 Oct 2022, at 04:53, Dan Stromberg wrote: > > > > On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson wrote: > > > >>> On 13Oct2022 03:25, Paulo da Silva > >>> wrote: > >>> There is another problem involved. The script, works fine except when >

Re: Find the path of a shell command [POSTPONED]

2022-10-16 Thread Barry
> On 16 Oct 2022, at 04:53, Dan Stromberg wrote: > > On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson wrote: > >>> On 13Oct2022 03:25, Paulo da Silva >>> wrote: >>> There is another problem involved. The script, works fine except when >>> launched by cron! Why? >> >> Record the script

Re: Find the path of a shell command [POSTPONED]

2022-10-15 Thread Dan Stromberg
On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson wrote: > On 13Oct2022 03:25, Paulo da Silva > wrote: > >There is another problem involved. The script, works fine except when > >launched by cron! Why? > > Record the script output: > > # record all output > exec >/tmp/script.$$.out 2>&1

systemd Re: Find the path of a shell command

2022-10-14 Thread Weatherby,Gerard
Only the first one or two require more work. The rest are your copy-pastes from the last time you did one. Typically I only have to changed descriptions, the executable in the *service and the timing in the *timer. They’re lot more readable and flexible than the cronjobs. From: Python-list

Re: Find the path of a shell command

2022-10-14 Thread Albert-Jan Roskam
On Oct 14, 2022 18:19, "Peter J. Holzer" wrote: On 2022-10-14 07:40:14 -0700, Dan Stromberg wrote: > Alternatively, you can "ps axfwwe" (on Linux) to see environment > variables, and check what the environment of cron (or similar) is.  It > is this environment (mostly)

Re: Find the path of a shell command

2022-10-14 Thread Peter J. Holzer
On 2022-10-14 07:40:14 -0700, Dan Stromberg wrote: > Alternatively, you can "ps axfwwe" (on Linux) to see environment > variables, and check what the environment of cron (or similar) is. It > is this environment (mostly) that cronjobs will inherit. The simplest (and IMHO also most reliable) way

Re: Find the path of a shell command

2022-10-14 Thread Dan Stromberg
On Wed, Oct 12, 2022 at 11:13 AM Paulo da Silva < p_d_a_s_i_l_v_a...@nonetnoaddress.pt> wrote: > Hi! > > The simple question: How do I find the full path of a shell command > (linux), i.e. how do I obtain the corresponding of, for example, > "type rm" in command line? > > The reason: > I have

Re: Find the path of a shell command

2022-10-13 Thread Michael Torrie
On 10/11/22 22:00, Paulo da Silva wrote: > Hi! > > The simple question: How do I find the full path of a shell command > (linux), i.e. how do I obtain the corresponding of, for example, > "type rm" in command line? > > The reason: > I have python program that launches a detached rm. It works

Re: Find the path of a shell command

2022-10-13 Thread Jon Ribbens via Python-list
On 2022-10-12, Paulo da Silva wrote: > Às 22:38 de 12/10/22, Jon Ribbens escreveu: >> On 2022-10-12, Jon Ribbens wrote: >>> On 2022-10-12, Paulo da Silva wrote: Às 19:14 de 12/10/22, Jon Ribbens escreveu: > On 2022-10-12, Paulo da Silva > wrote: >> Às 05:00 de 12/10/22, Paulo

Re: Find the path of a shell command

2022-10-13 Thread Eli the Bearded
In comp.lang.python, jkn wrote: > On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: >> I'm afraid you will have to look for the command in every path listed in >> the PATH environment variable. > erm, or try 'which rm' ? It is so hilarious seeing the responses to this thread.

Re: Find the path of a shell command

2022-10-13 Thread Mats Wichmann
On 10/12/22 14:51, Paulo da Silva wrote: Às 19:14 de 12/10/22, Jon Ribbens escreveu: On 2022-10-12, Paulo da Silva wrote: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding

Re: Find the path of a shell command [POSTPONED]

2022-10-12 Thread Cameron Simpson
On 13Oct2022 03:25, Paulo da Silva wrote: There is another problem involved. The script, works fine except when launched by cron! Why? Record the script output: # record all output exec >/tmp/script.$$.out 2>&1 # dump the envionment env | sort # turn on execution tracing

Re: Find the path of a shell command [POSTPONED]

2022-10-12 Thread Paulo da Silva
Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The reason: I have python program that launches a detached rm. It works pretty

Re: Find the path of a shell command

2022-10-12 Thread rbowman
On 10/12/22 09:06, Chris Green wrote: Michael F. Stemper wrote: On 12/10/2022 07.20, Chris Green wrote: jak wrote: Il 12/10/2022 09:40, jkn ha scritto: On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: I'm afraid you will have to look for the command in every path listed in

Re: Find the path of a shell command

2022-10-12 Thread Joe Pfeiffer
Cameron Simpson writes: > On 12Oct2022 20:54, Jon Ribbens wrote: >>On 2022-10-12, Jon Ribbens wrote: >>> On 2022-10-12, Joe Pfeiffer wrote: Jon Ribbens writes: > on Amazon Linux: > > $ which rm > /usr/bin/rm > $ sudo which rm > /bin/rm

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 22:38 de 12/10/22, Jon Ribbens escreveu: On 2022-10-12, Jon Ribbens wrote: On 2022-10-12, Paulo da Silva wrote: Às 19:14 de 12/10/22, Jon Ribbens escreveu: On 2022-10-12, Paulo da Silva wrote: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the

Re: Find the path of a shell command

2022-10-12 Thread Peter J. Holzer
On 2022-10-12 21:51:39 +0100, Paulo da Silva wrote: > Às 19:14 de 12/10/22, Jon Ribbens escreveu: > > If you're using subprocess.run / subprocess.Popen then the computer is > > *already* searching PATH for you. > Yes, and it works out of cron. > > Your problem must be that your cron > > job is

Re: Find the path of a shell command

2022-10-12 Thread Cameron Simpson
On 12Oct2022 20:54, Jon Ribbens wrote: On 2022-10-12, Jon Ribbens wrote: On 2022-10-12, Joe Pfeiffer wrote: Jon Ribbens writes: on Amazon Linux: $ which rm /usr/bin/rm $ sudo which rm /bin/rm Have some major Linux distributions not done usrmerge yet? For any that have,

Re: Find the path of a shell command

2022-10-12 Thread Cameron Simpson
On 13Oct2022 08:50, Cameron Simpson wrote: On 12Oct2022 15:16, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: rm doesn't take that long. Why are you detaching them? [...] For remove filesystems, even a local to your LAN NAS, it can take quite a while. Of course I meant "remote"

Re: Find the path of a shell command (shutil.which)

2022-10-12 Thread Eryk Sun
On 10/12/22, Weatherby,Gerard wrote: > > When no path is specified, the results of > os.environ() are used, > returning either the “PATH” value or a fallback of > os.defpath. The

Re: Find the path of a shell command

2022-10-12 Thread Jon Ribbens via Python-list
On 2022-10-12, Jon Ribbens wrote: > On 2022-10-12, Paulo da Silva wrote: >> Às 19:14 de 12/10/22, Jon Ribbens escreveu: >>> On 2022-10-12, Paulo da Silva wrote: Às 05:00 de 12/10/22, Paulo da Silva escreveu: > Hi! > > The simple question: How do I find the full path of a shell

Re: Find the path of a shell command

2022-10-12 Thread Cameron Simpson
On 12Oct2022 15:16, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: rm doesn't take that long. Why are you detaching them? For big things it takes quite a while. On slow discs it can take quite a while. For directory trees with many files it can take quite a while. For remove

Re: Find the path of a shell command (shutil.which)

2022-10-12 Thread Weatherby,Gerard
rning either the “PATH” value or a fallback of os.defpath<https://docs.python.org/3/library/os.html#os.defpath>. From: Python-list on behalf of Thomas Passin Date: Wednesday, October 12, 2022 at 5:39 PM To: python-list@python.org Subject: Re: Find the path of a shell command *** Attention: T

Re: Find the path of a shell command

2022-10-12 Thread Cameron Simpson
On 12Oct2022 17:49, Paulo da Silva wrote: Às 05:00 de 12/10/22, Paulo da Silva escreveu: I think that the the suggestion of searching the PATH env seems the best. I just want to note that you want to not just check for existence of the path, but that it is executable (permissionwise). You

Re: Find the path of a shell command

2022-10-12 Thread Thomas Passin
On 10/12/2022 12:00 AM, Paulo da Silva wrote: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The reason: I have python program that launches a detached rm. It works pretty

Re: Find the path of a shell command

2022-10-12 Thread Jon Ribbens via Python-list
On 2022-10-12, Paulo da Silva wrote: > Às 19:14 de 12/10/22, Jon Ribbens escreveu: >> On 2022-10-12, Paulo da Silva wrote: >>> Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain

Re: Find the path of a shell command

2022-10-12 Thread Weatherby,Gerard
env$$ 3. You can background Python just as well as you can a separate rm invocation. if os.fork() == 0: os.unlink(….) From: Python-list on behalf of Grant Edwards Date: Wednesday, October 12, 2022 at 5:03 PM To: python-list@python.org Subject: Re: Find the path of a sh

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 20:09 de 12/10/22, Antoon Pardon escreveu: Op 12/10/2022 om 18:49 schreef Paulo da Silva: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in

Re: Find the path of a shell command

2022-10-12 Thread jak
Il 12/10/2022 20:19, MRAB ha scritto: On 2022-10-12 06:11, jak wrote: Il 12/10/2022 06:00, Paulo da Silva ha scritto: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The

Re: Find the path of a shell command

2022-10-12 Thread Jon Ribbens via Python-list
On 2022-10-12, Jon Ribbens wrote: > On 2022-10-12, Joe Pfeiffer wrote: >> Jon Ribbens writes: >> >>> On 2022-10-12, Michael F. Stemper wrote: On 12/10/2022 07.20, Chris Green wrote: > ... and rm will just about always be in /usr/bin. On two different versions of Ubuntu, it's

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 19:14 de 12/10/22, Jon Ribbens escreveu: On 2022-10-12, Paulo da Silva wrote: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line?

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 20:16 de 12/10/22, 2qdxy4rzwzuui...@potatochowder.com escreveu: On 2022-10-12 at 17:43:18 +0100, Paulo da Silva wrote: Às 17:22 de 12/10/22, Tilmann Hentze escreveu: Paulo da Silva schrieb: I have python program that launches a detached rm. It works pretty well until it is invoked by

Re: Find the path of a shell command

2022-10-12 Thread Grant Edwards
On 2022-10-12, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 2022-10-12 at 17:43:18 +0100, Paulo da Silva > wrote: >> >> > Probably you could use os.unlink[1] with no problem. >> >> No, because I need to launch several rm's that keep running after the

Re: Find the path of a shell command

2022-10-12 Thread 2QdxY4RzWzUUiLuE
On 2022-10-12 at 17:43:18 +0100, Paulo da Silva wrote: > Às 17:22 de 12/10/22, Tilmann Hentze escreveu: > > Paulo da Silva schrieb: > > > I have python program that launches a detached rm. It works pretty well > > > until it is invoked by cron! I suspect that for cron we need to specify > > >

Re: Find the path of a shell command

2022-10-12 Thread Antoon Pardon
Op 12/10/2022 om 18:49 schreef Paulo da Silva: Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The reason: I have python

Re: Find the path of a shell command

2022-10-12 Thread jkn
On Wednesday, October 12, 2022 at 12:07:36 PM UTC+1, jak wrote: > Il 12/10/2022 09:40, jkn ha scritto: > > On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: > >> Il 12/10/2022 06:00, Paulo da Silva ha scritto: > >>> Hi! > >>> > >>> The simple question: How do I find the full path

Re: Find the path of a shell command

2022-10-12 Thread Jon Ribbens via Python-list
On 2022-10-12, Paulo da Silva wrote: > Às 05:00 de 12/10/22, Paulo da Silva escreveu: >> Hi! >> >> The simple question: How do I find the full path of a shell command >> (linux), i.e. how do I obtain the corresponding of, for example, >> "type rm" in command line? >> >> The reason: >> I have

Re: Find the path of a shell command

2022-10-12 Thread MRAB
On 2022-10-12 06:11, jak wrote: Il 12/10/2022 06:00, Paulo da Silva ha scritto: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The reason: I have python program that launches

Re: Find the path of a shell command

2022-10-12 Thread Jon Ribbens via Python-list
On 2022-10-12, Joe Pfeiffer wrote: > Jon Ribbens writes: > >> On 2022-10-12, Michael F. Stemper wrote: >>> On 12/10/2022 07.20, Chris Green wrote: ... and rm will just about always be in /usr/bin. >>> >>> On two different versions of Ubuntu, it's in /bin. >> >> It will almost always be in

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 17:22 de 12/10/22, Tilmann Hentze escreveu: Paulo da Silva schrieb: I have python program that launches a detached rm. It works pretty well until it is invoked by cron! I suspect that for cron we need to specify the full path. Probably you could use os.unlink[1] with no problem. No,

Re: Find the path of a shell command

2022-10-12 Thread Joe Pfeiffer
Jon Ribbens writes: > On 2022-10-12, Michael F. Stemper wrote: >> On 12/10/2022 07.20, Chris Green wrote: >>> ... and rm will just about always be in /usr/bin. >> >> On two different versions of Ubuntu, it's in /bin. > > It will almost always be in /bin in any Unix or Unix-like system, >

Re: Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Às 05:00 de 12/10/22, Paulo da Silva escreveu: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The reason: I have python program that launches a detached rm. It works pretty

Re: Find the path of a shell command

2022-10-12 Thread Michael F. Stemper
On 12/10/2022 07.20, Chris Green wrote: jak wrote: Il 12/10/2022 09:40, jkn ha scritto: On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: I'm afraid you will have to look for the command in every path listed in the PATH environment variable. erm, or try 'which rm' ? You

Re: Find the path of a shell command

2022-10-12 Thread Chris Green
Michael F. Stemper wrote: > On 12/10/2022 07.20, Chris Green wrote: > > jak wrote: > >> Il 12/10/2022 09:40, jkn ha scritto: > >>> On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: > > I'm afraid you will have to look for the command in every path listed in > the PATH

Re: Find the path of a shell command

2022-10-12 Thread Jon Ribbens via Python-list
On 2022-10-12, Michael F. Stemper wrote: > On 12/10/2022 07.20, Chris Green wrote: >> ... and rm will just about always be in /usr/bin. > > On two different versions of Ubuntu, it's in /bin. It will almost always be in /bin in any Unix or Unix-like system, because it's one of the fundamental

Re: Find the path of a shell command

2022-10-12 Thread jak
Il 12/10/2022 14:20, Chris Green ha scritto: jak wrote: Il 12/10/2022 09:40, jkn ha scritto: On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: Il 12/10/2022 06:00, Paulo da Silva ha scritto: Hi! The simple question: How do I find the full path of a shell command (linux), i.e.

Re: Find the path of a shell command

2022-10-12 Thread Chris Green
jak wrote: > Il 12/10/2022 09:40, jkn ha scritto: > > On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: > >> Il 12/10/2022 06:00, Paulo da Silva ha scritto: > >>> Hi! > >>> > >>> The simple question: How do I find the full path of a shell command > >>> (linux), i.e. how do I obtain

Re: Find the path of a shell command

2022-10-12 Thread jak
Il 12/10/2022 09:40, jkn ha scritto: On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: Il 12/10/2022 06:00, Paulo da Silva ha scritto: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type

Re: Find the path of a shell command

2022-10-12 Thread jkn
On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote: > Il 12/10/2022 06:00, Paulo da Silva ha scritto: > > Hi! > > > > The simple question: How do I find the full path of a shell command > > (linux), i.e. how do I obtain the corresponding of, for example, > > "type rm" in command

Re: Find the path of a shell command

2022-10-12 Thread jak
Il 12/10/2022 06:00, Paulo da Silva ha scritto: Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The reason: I have python program that launches a detached rm. It works pretty

Find the path of a shell command

2022-10-12 Thread Paulo da Silva
Hi! The simple question: How do I find the full path of a shell command (linux), i.e. how do I obtain the corresponding of, for example, "type rm" in command line? The reason: I have python program that launches a detached rm. It works pretty well until it is invoked by cron! I suspect that