Python的 - 远程登录 - 自动化APC PDU [英] Python - telnet - automation APC PDU
问题描述
我试图使用自动化内置的远程登录功能python的关闭连接的设备的APC PDU。我相信我能在用户名和密码进入,但在那之后我无法继续。我的code是如下:
I am attempting to automation turning off connected devices to an APC PDU using python's built in telnet functionality. I believe I am able to enter in the username and password, but I cannot proceed after that. My code is as follows:
telnet_session = telnetlib.Telnet(host=self.apc_ip)
self.logger.info("Entering APC Username")
telnet_session.read_until("User Name :")
telnet_session.write(self.apc_username + "\n")
self.logger.info("Entering APC Password")
telnet_session.read_until("Password :")
telnet_session.write(self.apc_password + "\n")
sleep(2)
print telnet_session.read_all()
我运行Windows,所以我相信 https://github.com/quackenbush/APC 是不是因为我不能安装Pexpect的一个选项。
I'm running windows so I believe that https://github.com/quackenbush/APC is not an option as I cannot install pexpect.
任何帮助将是AP preciated。
Any help would be appreciated.
谢谢,
PARTH
推荐答案
这个问题是我并没有发送正确的端线。
The issue was I wasn't sending the correct end line.
在窗户是\\ r \\ n,即没有的\\ n
In windows it's \r\n, not \n
这篇关于Python的 - 远程登录 - 自动化APC PDU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!