If you are able to configure public key authentication, you are not asked for a password (this is also true for ssh).
If this is set up you can use the -b option that comes with sftp (see man sftp) to execute commands automatically (although a script will also work, I guess).
Take a look at the following manpages for more detailed information:
sftp
ssh-keygen
Hope this helps.
|