Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6327437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:16:46+00:00 2026-05-24T17:16:46+00:00

First time poster, here, so go easy on me. :) Pretty sure nobody’s yet

  • 0

First time poster, here, so go easy on me. 🙂

Pretty sure nobody’s yet asked this in researching this question.

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 md5 file.txt. On Box 3, I want to run md5sum file.txt. I’m thining it’s an IF command where if the output of md5 is a failure, use md5sum instead. Just don’t know how to check and see whether the output of md5 is a failure or not


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: ftpget.sh file.txt

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.

The problem is this: The code is written to use md5, and while Box 1 uses md5, Box 3 uses md5sum. 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.

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: alias md5="md5sum"? That way, when the script runs on Box 3, it’ll execute md5 file.txt but the system will really execute md5sum file.txt since I created the alias.

Thoughts? Better ideas? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:16:47+00:00Added an answer on May 24, 2026 at 5:16 pm

    I don’t know what shell you’re using. This is for bash:

    #!/bin/sh
    md5=$(which md5)
    if [ ! "${md5}" ] ; then
      md5=$(which md5sum)
      if [ ! "${md5}" ] ; then
        echo "neither md5 nor md5sum found"
        exit 1
      fi
    fi
    ${md5} $0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a pretty simple question; first time poster and long time looker. Here
First time poster here. A quick question about setting up a loop here. I
first time poster - semi-newb to Rails. Here is my question. Suppose you have
Long time lurker, first time poster here. My question is: Using C# 2.0, is
This is my first time here so I apologize in advance if this question
First time poster here but definitely not a first time reader. My question is
first time poster. Please be gentle. This topic may be similar to several other
I'm first time poster here trying to pick up some Python skills; please be
Hey Everyone. I'm a first time poster, but I've browsed this site a number
I know that this is not the first time a question about this issue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.