广告
返回顶部
首页 > 资讯 > 操作系统 >linux expect 自动登录交换机保存配置的方法
  • 197
分享到

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

linuxexpect交换机配置 2022-06-04 23:06:07 197人浏览 独家记忆
摘要

telnet.exp 文件内容如下: #!/usr/bin/expect -f set ip [lindex $argv 0 ] set username [lindex $argv 1 ] se

telnet.exp 文件内容如下:


#!/usr/bin/expect -f 
 set ip [lindex $argv 0 ]   
 set username [lindex $argv 1 ]   
 set passWord [lindex $argv 2 ]  
 seETYAwt 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 自动登录交换机保存配置的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我们。

--结束END--

本文标题: linux expect 自动登录交换机保存配置的方法

本文链接: https://www.lsjlt.com/news/20499.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作