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:
#!/usr/bin sftp_user="pi" sftp_machine="192.168.2.11" eval sftp -b ftpregel $sftp_user@$sftp_machine rc=$? echo $rc if [ $rc -ne 0 ] then echo "$PROGNAME: ERROR in sftp!" fi
and the ftpregel that contains the ftp command looks like:
put GeileBeer.log quit