日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

except的实践经验

發布時間:2023/12/20 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 except的实践经验 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近爆發SMI安全問題, 公司有很多交換機都需要進行安全配置,所以要對200臺交換機進行配置,手工登錄的方式太慢。
現在有兩個思路 :

  • 使用Python的paramiko
  • 使用except
  • except代碼如下:
    === except.code===

    #!/usr/bin/expect -f# Set variables set hostname [lindex $argv 0] set username "user" set passwd "password1!"# Log resultslog_file -a ~/results.log# Announce which device we are working on and at what timesend_user "\n"# Don't check keysspawn ssh -c 3des -x -o StrictHostKeyChecking=no -l $ username $hostname# Allow this script to handle ssh connection issuesexpect {timeout { send_user "\nTimeout Exceeded - Check Host\n"; exit 1 }eof { send_user "\nSSH Connection To $hostname Failed\n"; exit 1 }"*#" {}"*assword:" {send "$passwd\r"}}expect "#"send "show vstack config\r"expect "#"send "conf ter\r"expect "#"send "no vstack\r"expect "#"send "end\r"expect "#"send "copy running-config startup-config\r"expect "*onfig]? "send "\r"expect "#"send "exit\n"

    使用方法:
    ./except.coode hostname/IP

    關于Password中特殊字符的說明:
    如果密碼中有&,#,$的, 處理的方式就是使用轉移符\,比如說&-> \&
    其他的符號應該不用轉義,比如說:!@%^*

    轉載于:https://blog.51cto.com/scantydd/2105603

    總結

    以上是生活随笔為你收集整理的except的实践经验的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。