Chinaunix首页 | 论坛 | 博客
  • 博客访问: 235559
  • 博文数量: 24
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 580
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-22 12:12
文章分类

全部博文(24)

文章存档

2011年(1)

2010年(5)

2009年(2)

2008年(16)

我的朋友

分类: LINUX

2010-08-10 17:00:08

[liuyx@higinet ~]$ cat liu.sh
#!/usr/bin/expect -f
set user [lindex $argv 0]
set pass [lindex $argv 1]
set ip [lindex $argv 2]
if {$argc<3} {
        puts stderr "Usage: $argv0  user password ip.\n "
        exit 1
}
set timeout 30
spawn scp -r aa.txt
while {1} {
        expect {
                "Are you sure you want to continue connecting (yes/no)?" {
                        send "yes\r"
                }
                "password:" {
                        send "$pass\r"
                }
                "Permission denied*" {
                        break
                }
                "*No route to host" {
                        break
                }
                "*No such file or directory" {
                        break
                }
                timeout {
                        break
                }
                eof {
                        break
                }
        }
}
#expect eof
#interact
exit 0
阅读(1281) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~