华域联盟 Linux linux expect 自动登录交换机保存配置的方法

linux expect 自动登录交换机保存配置的方法

linux expect 自动登录交换机保存配置的方法

 更新时间:2019年07月25日 10:09:30   作者:netfresh  
今天小编就为大家分享一篇linux expect 自动登录交换机保存配置的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

telnet.exp 文件内容如下:

#!/usr/bin/expect -f 
 set ip [lindex $argv 0 ]   
 set username [lindex $argv 1 ]   
 set password [lindex $argv 2 ]  
 set superpassword [lindex $argv 3 ] 
 set timeout 10          
 spawn telnet $ip
 expect {
 "name" { send "$username\\r";exp_continue }
 "*assword" { send "$password\\r"; exp_continue }
 "*>" { send "enable\\r" ; exp_continue }
 }


expect {
 "*assword" { send "$superpassword\\r"; exp_continue }
 "*#" { exp_send "wr \\r";}
 }

exp_send "quit\\r"
expect eof

命令执行:

./telnet.exp 192.168.0.80 admin cisco cisco

telnet.exp 命令后参数依次为交换机IP、登录账号、密码、enable密码。

以上这篇linux expect 自动登录交换机保存配置的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持华域联盟。

相关文章

最新评论

本文由 华域联盟 原创撰写:华域联盟 » linux expect 自动登录交换机保存配置的方法

转载请保留出处和原文链接:https://www.cnhackhy.com/4252.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

Linux磁盘配额管理图文案例

Linux中的进程守护supervisor安装配置及使用

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们