My altered Version:
Call it with ./scp_bkp.sh User Password BKPPath ServerIP
#!/usr/bin/expect -f
set USER [lrange $argv 0 0]
set PW [lrange $argv 1 1]
set BKPPath [lrange $argv 2 2]
set IP [lrange $argv 3 3]
# 1 User, 2 PW, 3 BkpPath, 4 IP
# trick to pass in command-line args to spawn
#eval spawn scp $argv
eval spawn scp $USER@$IP:/bootbank/state.tgz $BKPPath
expect "password: $"
send "$PW\n"
# wait for regular shell prompt before quitting
# probably a better way using 'wait'
expect "$ $"
Orginally taken from: http://tiebing.blogspot.com/2009/01/scp-with-automatic-password-input.html