Filippo Giunchedi wrote:
> I'm using md5sum in a shell script and I need to know wheter md5sum has
> failed because a file can't be read or md5sum mismatch. However md5sum
> exits always 1 regardless of the error. It would be useful to
> differentiate, e.g:
> 
> 1 - md5sum mismatch
> 2 - ENOENT
> 3 - ...

Remembering that there are various different md5sum implementations on
different systems (even on Debian!) it would be better to code this
explicitly in your script.  Perhaps something like this?

  MD5SUMFILE=somefile
  if [ ! -f $MD5SUMFILE ]; then
    echo Could not open $MD5SUMFILE 1>&2
    exit 1
  fi
  if ! md5sum -c $MD5SUMFILE; then
    echo Failed md5sum check with $MD5SUMFILE 1>&2
    exit 1
  fi
  exit 0

The above would work with the differerent md5sum implementations on
different systems.

Bob


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to