首先要準備兩個檔案,ip.txt 與 batTelnet.sh

ip.txt 如下:
-----------------------------------

192.168.1.11
192.168.2.22
192.168.3.33

-----------------------------------

 

batTelnet.sh 如下:
-----------------------------------

#!/bin/bash

username='root'

password='1234'
cmd1='show config'
for i in `cat ip.txt`
do
    (sleep 1;echo $username;sleep 1;echo $password;sleep 1;echo $cmd1;sleep 1)|telnet $i
done

-----------------------------------

dreamtails 發表在 痞客邦 PIXNET 留言(0) 人氣()