среда, 17 апреля 2013 г.


Expect - tool for automatically run interactive scripts.
Autoexpect - tool for generate expect script.
Generated code is dirty, but working, It will save many hours.

autoexpect ssh root@

work with script, after logout you receive script.exp which contain

 set timeout -1
spawn ssh root@
match_max 100000
expect -exact "Warning: Permanently added '' (RSA) to the list of known hosts.\r\r
root@'s password: "
send -- "testpass\r"
expect -exact "\r
Permission denied, please try again.\r\r
root@'s password: "
send -- "vagrant\r"
expect -exact "\r
Last login: Mon Mar 25 21:38:15 2013\r\r
^[\]0;root@centos64:~^G^[\[?1034h\[root@centos64 ~\]# "
send -- "uname -a\r"
expect -exact "uname -a\r
Linux centos64.vagrantup.com 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux\r
^[\]0;root@centos64:~^G\[root@centos64 ~\]# "
send -- "touch /tmp/123\r"
expect -exact "touch /tmp/123\r
^[\]0;root@centos64:~^G\[root@centos64 ~\]# "
send -- "exit\r"
expect eof

Отправить комментарий