Bash script to upload file

In many environment, we have a situation whereby a file must be transmitted via a script from one server to another. Assume we have a linux environment where Bash is installed. In that case, a sftp connection can be used. The principle is relatively simple: a sftp session is started from one machine to another. Via ftp commands, the file is transferred. But one may prefer to have a batch script that takes care of setting up the connection, transferring the file and closing the connection.
I assume that the two machines have set up a connection via private/ public keys. This avoids the necessity of having to provide a password.
One might use:



eval sftp -b ftpregel $sftp_user@$sftp_machine

echo $rc
        if [ $rc -ne 0 ]
                echo "$PROGNAME: ERROR in sftp!"

and the ftpregel that contains the ftp command looks like:

put GeileBeer.log