测试linux中expect的timeout参数的作用

 

[oracle@hosta ~]$ cat auto_transfer.sh 
#!/usr/bin/expect -f
set password oracle
#download
spawn scp /home/oracle/p10404530_112030_Linux-x86-64_1of7.zip oracle@192.168.188.167:/home/oracle/
set timeout 300
expect "oracle@192.168.188.167's password:"
set timeout 300  ------->>>>>>300表示300秒后超时,在超时之后,控制权会转移到下一行;若在超时时间之内,程序运行完,则控制权也会转移到下一行。
send "$password\r"
set timeout -1   ------->>>>>>注意此处的-1,-1表示永不超时,也就是:等 scp 命令正常执行完成之后,控制权会转移到下一行。
send "exit\r"
expect eof

[oracle@hosta ~]$
[oracle@hosta ~]$ ./auto_transfer.sh 
spawn scp /home/oracle/p10404530_112030_Linux-x86-64_1of7.zip oracle@192.168.188.167:/home/oracle/
oracle@192.168.188.167's password: 
p10404530_112030_Linux-x86-64_1of7.zip                              100% 1296MB   8.8MB/s   02:28    


目的端:

[oracle@single ~]$ ll
total 1358916
-rwxr--r--  1 oracle oinstall        183 Feb  5 16:32 auto.sh
drwxr-xr-x  8 oracle oinstall       4096 Sep 22  2011 database
drwxr-xr-x  4 oracle oinstall       4096 Dec  4 10:39 hvr
-rw-r-----  1 oracle oinstall      28672 Feb  5 17:07 lei1_01.dmp
-rw-r--r--  1 oracle oinstall       1194 Feb  2 17:10 lei1_imp.log
-rw-r--r--. 1 oracle oinstall   33020933 Nov  4 17:44 OPatch 11.2.0.3.6_p6880880_112000_Linux-x86-64.zip
-rw-r--r--  1 oracle oinstall 1358454646 Feb  5 17:37 p10404530_112030_Linux-x86-64_1of7.zip
-rwxr--r--  1 oracle oinstall        124 Feb  5 16:24 talk.sh
[oracle@single ~]$ 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值