Find the path of a shell command
Paulo da Silva
p_d_a_s_i_l_v_a_ns at nonetnoaddress.pt
Wed Oct 12 16:56:16 EDT 2022
À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 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?
>>>
>> Thank you all who have responded so far.
>> 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.
>
It seems you are right :-( I didn't think of that!
Does 'type' bash command work? I don't know how bash 'type' works.
I need to do some tests.
Thanks
Paulo
More information about the Python-list
mailing list