This is one of the many ways that you can use SFTP automatically using shell script and sshpass.
Steps:
sshpass -p <password> sftp <user>@<host> << !
<sftp commands (get,put,cd,lcd...)>
!
You can run your script if you are in the same directory using "./<filename>.sh" in terminal
SFTP is secure file transfer protocol. By using SFTP, you can transer files from a local machine to a remote machine.
1. From local machine, sftp into remote machine
2. Check what machine you are working on
example: pwd lpwd3. If neccessary, change into needed directory on local or remote machine.
example: to change directory on local machine: lcdto change directory on remote machine: cd4. In sftp user either get or put command to get or put files.
example: get example.jpg put example.jpg5. Exit SFTp
*** If you want to get a directory listing for remote machine use ls , for local machine directory listing use lls ***