bash Version Control Check-In

To make it easier to copy code from a development server to a version control server, check the file, then check it in, I created a bash script.

This script is also supported with ssh keys so the password does not need to be entered with each copy request. Thanks to: http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/

#!/bin/bash

# This script requires three parameters
#       server - The name of the server where the code will be retrieved from
#       file - The name of the file.  In this case, the path is hardcoded.
#       comment - A comment to include when checking in the file

if [ $# -lt 3 ]; then
        echo 'usage:'
        echo '        ~/get.sh server file comment'
else
        # Copy the file
        scp root@$1.domain.com:/opt/system/web/portal/$2 NEW

        # If the files can be compared
        if [ -r NEW -a -r "$2" ]; then

                # Create tmp file for the diff results
                TMP=`mktemp`
                diff NEW "$2" > "$TMP"

                # If the files are different
                if [ $? -ne 0 ]; then
                        more "$TMP"
                        echo -n 'Update? y/[n]? '
                        read
                        if [ $REPLY == 'y' ]; then
                                # Checkout the file
                                cleartool co -nc "$2"
                                # Copy the new file over
                                cp NEW $2
                                # Checkin the updated file
                                cleartool ci -c "$3" "$2"
                        else
                                echo 'no changes made'
                        fi
                else
                        echo 'files are the same'
                fi
                rm $TMP
        else
                echo 'scp failed or files missing'
        fi
fi

Thanks to:
http://www.cyberciti.biz/tips/shell-scripting-bash-how-to-create-temporary-random-file-name.html