Python中的Telnet功能

-1 投票
0 回答
29 浏览
提问于 2025-04-11 23:53

我正在尝试通过telnet连接一个设备,同时从一个文件中获取IP地址,但遇到了附带的错误。我将两个文件的代码作为图片附上。myswitches.pytest.py

    root@UbuntuDockerGuest-1:~# ./Test.py
    Enter your Telnet Username: david
    Password: 
    Configuring Switch 192.168.122.71

    Traceback (most recent call last):
      File "./Test.py", line 15, in <module>
        tn = telnetlib.Telnet(HOST)
      File "/usr/lib/python2.7/telnetlib.py", line 211, in __init__
        self.open(host, port, timeout)
      File "/usr/lib/python2.7/telnetlib.py", line 227, in open
        self.sock = socket.create_connection((host, port), timeout)
      File "/usr/lib/python2.7/socket.py", line 557, in create_connection
        for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    socket.gaierror: [Errno -2] Name or service not known

0 个回答

暂无回答

撰写回答