xshell脚本如何通过xftp自动上传到服务器

linux系统下,我现在本地有个txt文件,该如何编写xshell脚本,来实现,自动将txt文件通过xftp上传到服务器!
本人小白,来个完整可用的脚本代码,最好有注释,因为很多看不懂。谢谢各位大佬

脚本如下:
#!/usr/bin/expect -f
set password 密码
spawn scp 用户名@目标机器ip:拷贝文件的路径 存放本地文件的路径
set timeout 300
expect "用户名@目标机器ip's password:" #注意:这里的“用户名@目标机器ip” 跟上面的一致
set timeout 300
send "$password\r"
set timeout 300
send "exit\r"
expect eof
附:scp参数
-r:拷贝目录
-c:允许压缩
一个完整的例子
#!/usr/bin/expect -f
set password 123456
#download
spawn scp root@192.168.1.218:/root/a.wmv /home/yangyz/
set timeout 300
expect "root@192.168.1.218's password:"
set timeout 300
send "$password\r"
set timeout 300
send "exit\r"
expect eof
#upload
spawn scp /home/yangyz/abc.sql root@192.168.1.218:/root/test.sql
set timeout 300
expect "root@192.168.1.218's password:"
set timeout 300
send "$password\r"
set timeout 300
send "exit\r"
expect eof

#上传指定文件到ftp指定路径
putFtp(){
if [ $# -ne 5 ];then
MRM_DBG_LOG "global_func getFtp------->param error"
exit 1
fi
user=$1
password=$2
dir_f=$3
dir_l=$4
ip=$5
file_name=$6
ftp -ivn << EOF
open ${ip}
user ${user} ${password}
cd ${dir_f}
lcd ${dir_l}
put ${file_name}
close
quit
EOF
}

#!/usr/bin/expect -f
#Author by kevin
#date is 2011-11-14

set password vcdog
#download local host
spawn scp -r root@192.168.1.107:/root/dba_tool/test /root/DBA_TOOL/
set timeout 3
expect {
"yes/no" {send "yes\r";exp_continue}
}
expect "root@192.168.1.107's password:"
set timeout 3
send "$password\r"
set timeout 300
send "exit\r"
expect eof

#upload remote host
spawn scp -r /root/DBA_TOOL/t.txt root@192.168.1.107:/root/dba_tool/
set timeout 3
expect {
"yes/no" {send "yes\r";exp_continue}
}
expect "root@192.168.1.107's password:"
set timeout 3
send "$password\r"
set timeout 300
send "exit\r"
expect eof