The below is my script.
/usr/bin/expect<<EOD
spawn /usr/bin/sftp -o Port=$PORT $USER@$HOST
expect "sftp>"
expect "password:"
set timout 15
send "$password\r"
expect "sftp>"
send "lcd $remotedir\r"
expect "sftp>"
send "cd $lob\r"
expect "sftp>"
send "mkdir $newdir\r"
expect "sftp>"
send "cd $newdir\r"
expect "sftp>"
send "mput *.dat\r"
expect "sftp>"
log_file -noappend ls.out
send "ls\n"
expect "sftp>"
send "bye\r"