- 论坛徽章:
- 0
|
默认的使用“*”好像是不行的,csh特性,不是十分清楚。
但是使用-re参数后使用单独的“*”是报错的。
老兄,踏踏实实的写进去期待的字符呗,非要完全省事啊?
我提到的两种方法在我机器上测试是没有问题的- [root@bill cu]# more expect.sh
- #!/bin/bash
- expect << !
- set timeout -1
- spawn ssh bill@10.2.54.77
- expect {
- "(yes/no)?" {send -- "yes\r"; exp_continue}
- "password:" {send -- "123456\r"}
- }
- expect "]"
- send "touch a b c d e\r"
- expect "]"
- send "exit\r"
- !
- [root@bill cu]# sh expect.sh
- spawn ssh bill@10.2.54.77
- Address 10.2.54.77 maps to bogon, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
- bill@10.2.54.77's password:
- Last login: Tue Jun 21 18:06:51 2011 from 10.2.54.77
- [bill@bill ~]$ touch a b c d e
- [bill@bill ~]$ [root@bill cu]#
- [root@bill cu]# ll /home/bill/
- total 4
- -rw-rw-r-- 1 bill bill 0 Jun 21 18:17 a
- -rw-rw-r-- 1 bill bill 0 Jun 21 18:17 b
- -rw-rw-r-- 1 bill bill 0 Jun 21 18:17 c
- -rw-rw-r-- 1 bill bill 0 Jun 21 18:17 d
- -rw-rw-r-- 1 bill bill 0 Jun 21 18:17 e
- drwxrwxrwx 2 bill bill 4096 Feb 23 04:45 test
- [root@bill cu]#
复制代码 |
|