Python スクリプトは初めてですが、ネットワーク上の他のデバイスで動作するスクリプトを作成しました。リモート デバイスに構成を TFTP サーバーにバックアップするよう指示するスクリプトを変更しようとしています。私の 3Com、HP スイッチでは問題なく動作しますが、停止する DLINK POE スイッチを追加しただけです。コードは次のとおりです。
import getpass
import sys
import telnetlib
HOST = "10.3.5.90"
user = "admin"
password = "Password"
tn = telnetlib.Telnet(HOST)
tn.read_until("DGS-12010-10P login: ")
tn.write(user + "\r")
tn.read_until("Password: ")
tn.write(password + "\r")
tn.read_until("DGS-1210-10P> ")
tn.write("upload cfg_toTFTP tftp://10.5.5.2/DGS-1210-10P.bin" + "\r")
tn.read_until("DGS-1210-10P> ")
tn.write("logout" + "\r")
tn.close()
print "Backup Complete POE Switch"
私は常に以下の出力を取得し、タイムアウトします。30以上のデバイスで問題なく動作するため、何が間違っているのかわかりません
Traceback (most recent call last):
File "/backup/scripts/05-POE-switch.py", line 13, in <module>
tn.read_until("Password: ")
File "/usr/lib/python2.7/telnetlib.py", line 319, in read_until
return self.read_very_lazy()
File "/usr/lib/python2.7/telnetlib.py", line 395, in read_very_lazy
raise EOFError, 'telnet connection closed'
よろしくお願いします。