automate sftp interactive commands

It's well known how to exchange ssh keys so that you can log in to another system without  typing a password. But how to automate the rest of it?  For sftp, you can use a -b option and supply a 'batch' file, but other interactive system tasks don't let you do that. 

The answer is with command line redirection.  Here's an example with SFTP


#!/bin/bash
/opt/foo/some_command_that_creates_an_example_output_file"

if [[ $? ]]; then

echo "Sending BBC File"

sftp user@sftp.someplace.com << EOF
put /opt/foo/output.csv
exit
EOF

fi







Comments