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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
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 well until it is invoked by cron! I suspect that for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
I'm afraid you will have to look for the command in every path listed in
the PATH environment variable.
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!I'm afraid you will have to look for the command in every path listed in
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
the PATH environment variable.
erm, or try 'which rm' ?
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!I'm afraid you will have to look for the command in every path listed in
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
the PATH environment variable.
erm, or try 'which rm' ?
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!I'm afraid you will have to look for the command in every path listed in
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
the PATH environment variable.
erm, or try 'which rm' ?
(linux), i.e. how do I obtain the corresponding of, for example,
"type rm" in command line?
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!I'm afraid you will have to look for the command in every path listed in >> the PATH environment variable.
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 for cron we need to specify >>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
erm, or try 'which rm' ?
You might but if you don't know where the 'rm' command is, you will have
the same difficulty in using 'which' command. Do not you think?
jak <nospam@please.ty> wrote:
Il 12/10/2022 09:40, jkn ha scritto:From a command prompt use the bash built-in 'command' :-
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!I'm afraid you will have to look for the command in every path listed in >>>> the PATH environment variable.
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 for cron we need to specify >>>>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin? >>>>> What about other commands?
Thanks for any comments/responses.
Paulo
erm, or try 'which rm' ?
You might but if you don't know where the 'rm' command is, you will have
the same difficulty in using 'which' command. Do not you think?
command -v rm
... and rm will just about always be in /usr/bin.
jak <nospam@please.ty> wrote:
Il 12/10/2022 09:40, jkn ha scritto:
On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote:
From a command prompt use the bash built-in 'command' :-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 might but if you don't know where the 'rm' command is, you will have
the same difficulty in using 'which' command. Do not you think?
command -v rm
... and rm will just about always be in /usr/bin.
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.
On 12/10/2022 07.20, Chris Green wrote:
jak <nospam@please.ty> wrote:
Il 12/10/2022 09:40, jkn ha scritto:
On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote:
From a command prompt use the bash built-in 'command' :-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 might but if you don't know where the 'rm' command is, you will have >> the same difficulty in using 'which' command. Do not you think?
command -v rm
... and rm will just about always be in /usr/bin.
On two different versions of Ubuntu, it's in /bin.
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
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.
Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> schrieb:No, because I need to launch several rm's that keep running after the
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.
On 2022-10-12, Michael F. Stemper <michael.stemper@gmail.com> 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 utilities that may be vital in
fixing the system when it's booted in single-user mode and /usr may
not be available. Also, the Filesystem Hierarchy Standard *requires*
it to be in /bin.
Having said that, nothing requires it not to be elsewhere *as well*,
and in Ubuntu and other Linux systems it is in /usr/bin too. And because
PATH for non-root users will usually contain /usr/bin before /bin (or
indeed may not contain /bin at all), 'command -v rm' or 'which rm' will usually list the version of rm that is in /usr/bin.
e.g. on Amazon Linux:
$ which rm
/usr/bin/rm
$ sudo which rm
/bin/rm
Jon Ribbens <jon+usenet@unequivocal.eu> writes:
On 2022-10-12, Michael F. Stemper <michael.stemper@gmail.com> 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 utilities that may be vital in
fixing the system when it's booted in single-user mode and /usr may
not be available. Also, the Filesystem Hierarchy Standard *requires*
it to be in /bin.
Having said that, nothing requires it not to be elsewhere *as well*,
and in Ubuntu and other Linux systems it is in /usr/bin too. And because
PATH for non-root users will usually contain /usr/bin before /bin (or
indeed may not contain /bin at all), 'command -v rm' or 'which rm' will
usually list the version of rm that is in /usr/bin.
e.g. 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, /bin is a symbolic link to /usr/bin
Às 05:00 de 12/10/22, Paulo da Silva escreveu:
Hi!Thank you all who have responded so far.
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
I think that the the suggestion of searching the PATH env seems the best. Another thing that I thought of is that of the 'which', but, to avoid
the mentioned recurrent problem of not knowing where 'which' is I would
use 'type' instead. 'type' is a bash (sh?) command.
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!I'm afraid you will have to look for the command in every path listed in >> the PATH environment variable.
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 for cron we need to specify >>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
erm, or try 'which rm' ?You might but if you don't know where the 'rm' command is, you will have
the same difficulty in using 'which' Command. Do not you think?
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 well
until it is invoked by cron! I suspect that for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
I'm afraid you will have to look for the command in every path listed in
the PATH environment variable.
Às 05:00 de 12/10/22, Paulo da Silva escreveu:
Hi!Thank you all who have responded so far.
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 for cron we need to
specify the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
I think that the the suggestion of searching the PATH env seems the best.
Às 17:22 de 12/10/22, Tilmann Hentze escreveu:
Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> 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, because I need to launch several rm's that keep running after the script ends.
On 2022-10-12 at 17:43:18 +0100,
Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote:
Às 17:22 de 12/10/22, Tilmann Hentze escreveu:
Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> schrieb:No, because I need to launch several rm's that keep running after the script >> ends.
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.
rm doesn't take that long. Why are you detaching them?
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote:Yes, and it works out of cron.
Às 05:00 de 12/10/22, Paulo da Silva escreveu:
Hi!Thank you all who have responded so far.
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
I think that the the suggestion of searching the PATH env seems the best.
Another thing that I thought of is that of the 'which', but, to avoid
the mentioned recurrent problem of not knowing where 'which' is I would
use 'type' instead. 'type' is a bash (sh?) command.
If you're using subprocess.run / subprocess.Popen then the computer is *already* searching PATH for you.
Your problem must be that your cronI could do that, but I am using /etc/cron.* for convenience.
job is being run without PATH being set, perhaps you just need to edit
your crontab to set PATH to something sensible.
Or just hard-code yourIt can also be in /bin, at least.
program to run '/bin/rm' explicitly, which should always work (unless
you're on Windows, of course!)
On 2022-10-12, Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote:
Jon Ribbens <jon+usenet@unequivocal.eu> writes:
On 2022-10-12, Michael F. Stemper <michael.stemper@gmail.com> 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 utilities that may be vital in
fixing the system when it's booted in single-user mode and /usr may
not be available. Also, the Filesystem Hierarchy Standard *requires*
it to be in /bin.
Having said that, nothing requires it not to be elsewhere *as well*,
and in Ubuntu and other Linux systems it is in /usr/bin too. And because >>> PATH for non-root users will usually contain /usr/bin before /bin (or
indeed may not contain /bin at all), 'command -v rm' or 'which rm' will
usually list the version of rm that is in /usr/bin.
e.g. 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, /bin is a symbolic link to /usr/bin
I have immediate access to CentOS 7, Ubuntu 20, and Amazon Linux 2,
and none of those have done that.
Op 12/10/2022 om 18:49 schreef Paulo da Silva:
Às 05:00 de 12/10/22, Paulo da Silva escreveu:
Hi!Thank you all who have responded so far.
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 for cron we need to
specify the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
I think that the the suggestion of searching the PATH env seems the best.
I fear that won't work.
If it doesn't work in cron, that probably means, PATH is not set
properly in your cron environment. And if PATH is not set properly,
searching it explicitely won't work either.
On 2022-10-12 at 17:43:18 +0100, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> 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 script >> ends.
rm doesn't take that long.
On 2022-10-12 06:11, jak wrote:
Il 12/10/2022 06:00, Paulo da Silva ha scritto:Isn't that what the "whereis" command does?
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 for cron we need to
specify the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
I'm afraid you will have to look for the command in every path listed in
the PATH environment variable.
Às 19:14 de 12/10/22, Jon Ribbens escreveu:
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote: >>> Às 05:00 de 12/10/22, Paulo da Silva escreveu:Yes, and it works out of cron.
Hi!Thank you all who have responded so far.
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 for cron we need to specify >>>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
I think that the the suggestion of searching the PATH env seems the best. >>> Another thing that I thought of is that of the 'which', but, to avoid
the mentioned recurrent problem of not knowing where 'which' is I would
use 'type' instead. 'type' is a bash (sh?) command.
If you're using subprocess.run / subprocess.Popen then the computer is
*already* searching PATH for you.
Your problem must be that your cronI could do that, but I am using /etc/cron.* for convenience.
job is being run without PATH being set, perhaps you just need to edit
your crontab to set PATH to something sensible.
Or just hard-code yourIt can also be in /bin, at least.
program to run '/bin/rm' explicitly, which should always work (unless
you're on Windows, of course!)
A short idea is to just check /bin/rm and /usr/bin/rm, but I prefer
searching thru PATH env. It only needs to do that once.
On 2022-10-12 at 17:43:18 +0100, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> 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 script >> ends.
rm doesn't take that long.
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote:
Às 19:14 de 12/10/22, Jon Ribbens escreveu:
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote: >>>> Às 05:00 de 12/10/22, Paulo da Silva escreveu:Yes, and it works out of cron.
Hi!Thank you all who have responded so far.
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 for cron we need to specify >>>>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin? >>>>> What about other commands?
I think that the the suggestion of searching the PATH env seems the best. >>>> Another thing that I thought of is that of the 'which', but, to avoid
the mentioned recurrent problem of not knowing where 'which' is I would >>>> use 'type' instead. 'type' is a bash (sh?) command.
If you're using subprocess.run / subprocess.Popen then the computer is
*already* searching PATH for you.
Your problem must be that your cronI could do that, but I am using /etc/cron.* for convenience.
job is being run without PATH being set, perhaps you just need to edit
your crontab to set PATH to something sensible.
Or just hard-code yourIt can also be in /bin, at least.
program to run '/bin/rm' explicitly, which should always work (unless
you're on Windows, of course!)
I assume you mean /usr/bin. But it doesn't matter. As already
discussed, even if 'rm' is in /usr/bin, it will be in /bin as well
(or /usr/bin and /bin will be symlinks to the same place).
A short idea is to just check /bin/rm and /usr/bin/rm, but I prefer
searching thru PATH env. It only needs to do that once.
I cannot think of any situation in which that will help you. But if for
some reason you really want to do that, you can use the shutil.which() function from the standard library:
>>> import shutil
>>> shutil.which('rm')
'/usr/bin/rm'
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
Thanks for any comments/responses.
Paulo
À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.
Another thing that I thought of is that of the 'which', but, to avoid
the mentioned recurrent problem of not knowing where 'which' is I
would use 'type' instead.
'type' is a bash (sh?) command.
rm doesn't take that long. Why are you detaching them?
On 2022-10-12, Jon Ribbens <jon+usenet@unequivocal.eu> wrote:Except that you can't have parallel tasks, at least in an easy way.
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote: >>> Às 19:14 de 12/10/22, Jon Ribbens escreveu:
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote:Yes, and it works out of cron.
Às 05:00 de 12/10/22, Paulo da Silva escreveu:
Hi!Thank you all who have responded so far.
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 for cron we need to specify >>>>>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin? >>>>>> What about other commands?
I think that the the suggestion of searching the PATH env seems the best. >>>>> Another thing that I thought of is that of the 'which', but, to avoid >>>>> the mentioned recurrent problem of not knowing where 'which' is I would >>>>> use 'type' instead. 'type' is a bash (sh?) command.
If you're using subprocess.run / subprocess.Popen then the computer is >>>> *already* searching PATH for you.
Your problem must be that your cronI could do that, but I am using /etc/cron.* for convenience.
job is being run without PATH being set, perhaps you just need to edit >>>> your crontab to set PATH to something sensible.
Or just hard-code yourIt can also be in /bin, at least.
program to run '/bin/rm' explicitly, which should always work (unless
you're on Windows, of course!)
I assume you mean /usr/bin. But it doesn't matter. As already
discussed, even if 'rm' is in /usr/bin, it will be in /bin as well
(or /usr/bin and /bin will be symlinks to the same place).
A short idea is to just check /bin/rm and /usr/bin/rm, but I prefer
searching thru PATH env. It only needs to do that once.
I cannot think of any situation in which that will help you. But if for
some reason you really want to do that, you can use the shutil.which()
function from the standard library:
>>> import shutil
>>> shutil.which('rm')
'/usr/bin/rm'
Actually if I'm mentioning shutil I should probably mention
shutil.rmtree() as well, which does the same as 'rm -r', without
needing to find or run any other executables.
On 12Oct2022 15:16, Dan Sommers <2QdxY4RzWzUUiLuE@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.
On 2022-10-12, Jon Ribbens <jon+usenet@unequivocal.eu> wrote:
On 2022-10-12, Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote:
Jon Ribbens <jon+usenet@unequivocal.eu> 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, /bin is a symbolic link to /usr/bin
I have immediate access to CentOS 7, Ubuntu 20, and Amazon Linux 2,
and none of those have done that.
Sorry, in fact they have done that - I misread your comment as being
that they had symlinked the executables not the directories. This seems
quite an unwise move to me but presumably they've thought it through.
À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 being run without PATH being set, perhaps you just need to edit
your crontab to set PATH to something sensible.
I could do that, but I am using /etc/cron.* for convenience.
On 12Oct2022 20:54, Jon Ribbens <jon+usenet@unequivocal.eu> wrote:
On 2022-10-12, Jon Ribbens <jon+usenet@unequivocal.eu> wrote:
On 2022-10-12, Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote:
Jon Ribbens <jon+usenet@unequivocal.eu> 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, /bin is a symbolic link to /usr/bin
The above example may just be a different ordering in $PATH.
Michael F. Stemper <michael.stemper@gmail.com> wrote:
On 12/10/2022 07.20, Chris Green wrote:I think you'll find it's in both /bin and /usr/bin, usually /usr/bin
jak <nospam@please.ty> wrote:
Il 12/10/2022 09:40, jkn ha scritto:
On Wednesday, October 12, 2022 at 6:12:23 AM UTC+1, jak wrote:
From a command prompt use the bash built-in 'command' :-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 might but if you don't know where the 'rm' command is, you will have >>>> the same difficulty in using 'which' command. Do not you think?
command -v rm
... and rm will just about always be in /usr/bin.
On two different versions of Ubuntu, it's in /bin.
is earlier in the path so /usr/bin/rm is the one that will normally be
found first.
It's only in /bin/rm in case one has a system which mounts /bin
separately and earlier in the boot sequence and rm is one of the
commands needed early on.
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
There is another problem involved. The script, works fine except when >launched by cron! Why?
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 inerm, or try 'which rm' ?
the PATH environment variable.
Às 22:38 de 12/10/22, Jon Ribbens escreveu:
On 2022-10-12, Jon Ribbens <jon+usenet@unequivocal.eu> wrote:Except that you can't have parallel tasks, at least in an easy way.
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote: >>>> Às 19:14 de 12/10/22, Jon Ribbens escreveu:
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> wrote:Yes, and it works out of cron.
Às 05:00 de 12/10/22, Paulo da Silva escreveu:
Hi!Thank you all who have responded so far.
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 for cron we need to specify >>>>>>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin? >>>>>>> What about other commands?
I think that the the suggestion of searching the PATH env seems the best.
Another thing that I thought of is that of the 'which', but, to avoid >>>>>> the mentioned recurrent problem of not knowing where 'which' is I would >>>>>> use 'type' instead. 'type' is a bash (sh?) command.
If you're using subprocess.run / subprocess.Popen then the computer is >>>>> *already* searching PATH for you.
Your problem must be that your cronI could do that, but I am using /etc/cron.* for convenience.
job is being run without PATH being set, perhaps you just need to edit >>>>> your crontab to set PATH to something sensible.
Or just hard-code yourIt can also be in /bin, at least.
program to run '/bin/rm' explicitly, which should always work (unless >>>>> you're on Windows, of course!)
I assume you mean /usr/bin. But it doesn't matter. As already
discussed, even if 'rm' is in /usr/bin, it will be in /bin as well
(or /usr/bin and /bin will be symlinks to the same place).
A short idea is to just check /bin/rm and /usr/bin/rm, but I prefer
searching thru PATH env. It only needs to do that once.
I cannot think of any situation in which that will help you. But if for
some reason you really want to do that, you can use the shutil.which()
function from the standard library:
>>> import shutil
>>> shutil.which('rm')
'/usr/bin/rm'
Actually if I'm mentioning shutil I should probably mention
shutil.rmtree() as well, which does the same as 'rm -r', without
needing to find or run any other executables.
Using Popen I just launch rm's and end the script.
Às 19:14 de 12/10/22, Jon Ribbens escreveu:
On 2022-10-12, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt>Yes, and it works out of cron.
wrote:
Às 05:00 de 12/10/22, Paulo da Silva escreveu:
Hi!Thank you all who have responded so far.
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 for cron we need to specify >>>> the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
I think that the the suggestion of searching the PATH env seems the
best.
Another thing that I thought of is that of the 'which', but, to avoid
the mentioned recurrent problem of not knowing where 'which' is I would
use 'type' instead. 'type' is a bash (sh?) command.
If you're using subprocess.run / subprocess.Popen then the computer is
*already* searching PATH for you.
Your problem must be that your cronI could do that, but I am using /etc/cron.* for convenience.
job is being run without PATH being set, perhaps you just need to edit
your crontab to set PATH to something sensible.
Or just hard-code yourIt can also be in /bin, at least.
program to run '/bin/rm' explicitly, which should always work (unless
you're on Windows, of course!)
A short idea is to just check /bin/rm and /usr/bin/rm, but I prefer searching thru PATH env. It only needs to do that once.
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
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 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 for cron we need to specify
the full path.
Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
What about other commands?
On 13Oct2022 03:25, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> 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
set -x
... rest of the script
and have a look afterwards. Cron's environment is very minimal. This
will show you what's in it.
On 16 Oct 2022, at 04:53, Dan Stromberg <drsalists@gmail.com> wrote:
On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson <cs@cskk.id.au> wrote:
On 13Oct2022 03:25, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> >>> 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
set -x
... rest of the script
and have a look afterwards. Cron's environment is very minimal. This
will show you what's in it.
Careful. On some systems if someone restarts the cron daemon, it could
pick up a larger environment than after being started on boot.
--
https://mail.python.org/mailman/listinfo/python-list
[... script deleted ...]On 16 Oct 2022, at 04:53, Dan Stromberg <drsalists@gmail.com> wrote:
On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson <cs@cskk.id.au> wrote:
On 13Oct2022 03:25, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> >>> wrote:
There is another problem involved. The script, works fine except when
launched by cron! Why?
Cron's environment is very minimal. This will show you what's in
it.
Careful. On some systems if someone restarts the cron daemon, it could pick up a larger environment than after being started on boot.
That have to a old system that does not use systemd.
Is there a specific system that still does this?
On Mi 12 Okt 2022 at 05:00, Paulo da Silva <p_d_a_s_i_l_v_a_ns@nonetnoaddress.pt> 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 pretty
well until it is invoked by cron! I suspect that for cron we need
to specify the full path.
Why not just use os.unlink ?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 33:33:05 |
Calls: | 10,391 |
Calls today: | 2 |
Files: | 14,064 |
Messages: | 6,417,129 |