#!/usr/bin/expect -f set ip [lindex $argv 0] set dir [lindex $argv 1] set file [lindex $argv 2] set timeout 10 spawn ftp $ip expect "Name*" send "root\r" expect "Password*" send "huawei\r" expect "ftp>*" send "lcd $dir\r" expect { "*file" {send_user "local $dir no such file or dir";send "quit\r"} "*now*" {send "put $dir/$file d:/serv_u_root/$file\r"} } expect { "*Failed" {send_user "remote $file no such file";send "quit\r"} "*OK" {send_user "$file has been uploaded.";send "quit\r"} } expect eof