Am Thu, Mar 16, 2023 at 07:27:22AM -0400 schrieb Greg Wooledge: > On Thu, Mar 16, 2023 at 12:24:10PM +0100, Christoph Brinkhaus wrote: > > The environments of login shells and crontab can be different. This > > includes the path where to seek executables. Therefore it is good > > practice not to write just the name of the executable as nc but the > > name with the path as /usr/bin/nc. Here I took nc as an example. > > It's better to set the PATH variable to whatever you need it to be. > Then you don't have to hard-code the execution path of every single > command in the script. (Which means your script breaks when you move > it to a system where nc is in /bin instead of /usr/bin, and so on.) > I think you are right. The only remaining argument for specifying the complete path I have read about is as below. There might be the situation with different binaries but similar names. For example /usr/bin/nc is different to /bin/nc. But such a system should be a nightmare and I doubt if you can find such an installation in the wild.
I have a few scripts which should run at Linux and FreeBSD. In the past I have used uname to distinguish the platforms. This works but it is bulky and ugly. Things will be fine if I concat the PATH required for both systems and follow your advise. Thank you and kind regards, Christoph -- Ist die Katze gesund schmeckt sie dem Hund.