#!/usr/bin/expect
set USERNAME [lindex $argv 0]
set PASSWORD [lindex $argv 1]
set RADDRESS [lindex $argv 2]
set FILENAME [lindex $argv 3]
spawn sftp $USERNAME@$RADDRESS
set timeout 30
expect "$USERNAME@$RADDRESS's password: "
set timeout 30
send "$PASSWORD\r"
set timeout 30
expect "sftp> "
set timeout 30
send "put ${FILENAME} share/${FILENAME}\r"
send "exit\r"
expect eof
set USERNAME [lindex $argv 0]
set PASSWORD [lindex $argv 1]
set RADDRESS [lindex $argv 2]
set FILENAME [lindex $argv 3]
spawn sftp $USERNAME@$RADDRESS
set timeout 30
expect "$USERNAME@$RADDRESS's password: "
set timeout 30
send "$PASSWORD\r"
set timeout 30
expect "sftp> "
set timeout 30
send "put ${FILENAME} share/${FILENAME}\r"
send "exit\r"
expect eof