ftp 交互脚本

expect ftp 交互

yum -y install expect

vim ftp_upload.sh
#!/usr/bin/expect
spawn ftp localhost  
expect "Name*"     
send "ftp\n"         
expect "ftp>*"
send "cd pub/other\n"
expect "ftp>*"
send "put /tmp/123.txt xo.txt\n"
expect {
        "150 Ok to send data" { send_user "upload sucessfull!";send "quit\n" }  #send_user 类型shell的echo命令
        "553*" { send_user "upload error!";send "quit\n" }
}
expect eof

加权限 chmod +x ftp_upload.sh
执行命令 ./ftp_upload.sh

猜你喜欢

转载自www.cnblogs.com/gaiting/p/12149191.html
FTP