#!/usr/bin/expect -f set host [lindex $argv 0] set password [lindex $argv 1] set rules [lindex $argv 2] set timeout 85 spawn -noecho ssh $host expect { "*yes/no" {send "yes\r";exp_continue} "*password:" {send "$password\r";exp_continue} "*<config/policys>#" {foreach element [ split [lindex $argv 2] "," ] { send "$element\r save\r"}} "*<config>#" {send "policys\r"; exp_continue} "*>" {send "config\r"; exp_continue} } send "exit\r" send "exit\r" send "exit\r" expect eof
分类:Linux
标签: