title: Shell scripts and the md5/md5sum command: need to decide when to use which one
body: <p>First time poster, here, so go easy on me. :)</p>
  
  <p>Pretty sure nobody's yet asked this in researching this question.</p>
  
  <p>Short version: How can I tell a shell script to use one command versus the other, depending on which box I run the shell script on? Example: on Box 1, I want to run <code>md5 file.txt</code>. On Box 3, I want to run <code>md5sum file.txt</code>. I'm thining it's an IF command where if the output of <code>md5</code> is a failure, use <code>md5sum</code> instead. Just don't know how to check and see whether the output of <code>md5</code> is a failure or not</p>
  
  <hr>
  
  <p>Long version: I have 3 boxes that I work with. Box 1 and 3 are the receivers of a file from Box 2, and they receive the file when I invoke a script on box 1/3 as follows: <code>ftpget.sh file.txt</code></p>
  
  <p>I have a shell script that does an FTP GET and grabs a file from Box 2. It then does an md5 on the source file from Box 2 and the destination file, which'll be on Box 1 or 3, depending on which one I executed the script from. The hashes must match, of course.</p>
  
  <p>The problem is this: The code is written to use <code>md5</code>, and while Box 1 uses md5, Box 3 uses <code>md5sum</code>. So when I execute the script from Box 1, it works great. When I execute the script from Box 3, it fails because Box 3 uses md5sum, not md5.</p>
  
  <p>So I was thinking: what's the best way to handle this? I can't install anything since I'm not an admin, and the people who manage the machine probably won't do it for me anyway. Could I just create an alias in my .profile which goes something like: <code>alias md5="md5sum"</code>? That way, when the script runs on Box 3, it'll execute <code>md5 file.txt</code> but the system will really execute <code>md5sum file.txt</code> since I created the alias.</p>
  
  <p>Thoughts? Better ideas? :)</p>