補覺鳴詩

學海無涯


  • 首頁

  • archive

  • 關於我

  • 搜尋

centos 排程 遠端指令

時間: 2018-09-01   |   分類: Centos 7   | 字數: 154 字 | 閱讀: 1分鐘 | 閱讀次數:

yum -y install expect

switchBK.sh

chmod 775 switch.sh

建立 shell

#!/usr/bin/expect
## TomDV
## http://blog.penumbra.be/2010/02/expect-scripts-backup-cisco-config/

set timeout 600

# —————- configuration device —————- #

## device 1
set device1
set tftp
set device1_user
set device1_pass

# ————– run command ————– #

## device 1
spawn ssh -l $user $device
expect “Password:”
send “$passn”
expect “#”
send “copy running-config tftp://$tftpn”
expect “$tftp”
send “n”
expect “Destination”
send “n”
expect copied
send “exitn”

comments powered by Disqus >
Owan

Owan

愛貓如癡

131 日誌
29 分類
37 標籤
GitHub
© 2010 - 2022 補覺鳴詩
Powered by - Hugo v0.96.0 / Theme by - NexT
0%