Autoexpect - tool for generate expect script.
Generated code is dirty, but working, It will save many hours.
Example:
autoexpect ssh root@192.168.122.240
work with script, after logout you receive script.exp which contain
set timeout -1
spawn ssh root@192.168.122.240
match_max 100000
expect -exact "Warning: Permanently added '192.168.122.240' (RSA) to the list of known hosts.\r\r
root@192.168.122.240's password: "
send -- "testpass\r"
expect -exact "\r
Permission denied, please try again.\r\r
root@192.168.122.240'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
Комментариев нет:
Отправить комментарий