Sftp through script

hi,

I have a requirement where i need to sftp the file from another server.

Let me describe in detail:

when i login into putty i use my id i.e. kusvi and then i start another acc i.e.cdram where all development works takes place...so if i am in cdram and i need to do sftp i have to exit from this account and go to kusvi account...

Till now i was doing sftp in following manner:
**Assume i am in g210.as.com server and getting file from g211.as.com

[cdradm]$cd
[cdradm]$exit
[kusvi]$sftp g211.as.com
Connecting to g211.as.com
Password:********
sftp>cd scripts
sftp>get sample.txt
sftp>bye
[kusvi]$cp sample.txt scripts
[kusvi]$. .b_pro
[cdradm]$cd scripts
[cdradm scripts]$ls
sample.txt

All steps showed above is just to provide an overview of my manual sftp. But i need to do sftp files from g211.as.com to g210.as.com

Please help me on this how to achieve this.

NOTE:: i can sftp through kusvi account only and need to send password as argument.

TIA:b:

Have you considered ssh keys? Also, try a utility, sshpass, which allows batch processing using a password. This is only available on some platforms. You can also write an expect script.

you can sftp as another user this way

sshpass -p [password] sftp username@servnername << -EOF
cd /some/path
get filename
exit
EOF

Knowing your OS would help to get you a good answer.