We are migrating some servers from HP-UX to Linux RedHat, and we have to migrate about 100 shell scripts that are referencing /usr/bin/mailx (instead of /bin/mailx on Linux).

We'd like to change all the 100 scripts (from /usr/bin/mailx to /bin/mailx) only if this is the last option.

Are there better ways of doing this?

P.S.: our system administrators don't want to create a symbolic lynk "/usr/bin/mailx" pointing to /bin/mailx (I didn't understand why, actually).

Thanks in advance.

  • Solution that came to my mind 5 minutes ago (ugly but probably effective): in .profile -> alias "/usr/bin/mailx"="/bin/mailx" – Gabriele D'Antona Apr 2 '14 at 20:58

Maybe the sysadmin would like to use the alternatives system instead of just plunking a symlink into /usr/bin:

alternatives --install /usr/bin/mailx mailx /bin/mailx 10

This essentially does this:

/usr/bin/mailx -> /etc/alternatives/mailx
/etc/alternatives/mailx -> /bin/mailx

It's more complicated, so therefore it might be better ;)

  • Didn't know of "alternatives". What's the purpose of this command? It acts very similarly to a symbolic link... – Gabriele D'Antona Apr 2 '14 at 21:02
  • 1
    It's a symbolic link manager, basically. It allows you to install different versions of tools (such as java) and easily control which one is "visible" – glenn jackman Apr 2 '14 at 21:23
  • I read in the manual there are Red Hat specific options. Is that manager only available to Debian based distributions? – user44370 Apr 2 '14 at 21:51
  • Nope, redhat has it. – glenn jackman Apr 2 '14 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.