这是我的telnetlib代码:
HOST = "@ip"
user = "Hichem"
password = "Hichem"
tn = telnetlib.Telnet(HOST)
tn.read_until("Connexion : ")
tn.write(user+ '\r\n')
if password:
tn.read_until("Mot de passe de Hichem : ")
tn.write(password+ '\r\n')
好。我成功访问了服务器。
我想在文件中获取命令的结果(Restrictions.txt)。
结果是:
(Number of results = 1)
--- END
LST IOR:,LP=1,D=K'189159;
+++ KOUBA 2016-03-27 09:22:56+01:00
O&M #617392
%%LST IOR:,LP=1,D=K'189159;%%
RETCODE = 0 Operation succeeded
ESL/EDCN call-in and call-out authority
---------------------------------------
Subscriber number = 189159
Local DN set = 1
Call-out authority = Intra-office
= Local
= Local toll
= National toll
= International toll
= Intra-Centrex
= Outgoing Centrex
= Intra-office national toll
= Intra-office international toll
= Intra-centrex local toll
= Intra-centrex national toll
= Intra-centrex international toll
= Intra-office local toll
= Customize call-out authority 1
= Customize call-out authority 2
= Customize call-out authority 3
= Customize call-out authority 4
= Customize call-out authority 7
= Customize call-out authority 9
= Customize call-out authority 10
= Customize call-out authority 11
= Customize call-out authority 12
= Customize call-out authority 13
= Customize call-out authority 14
= Customize call-out authority 15
= Customize call-out authority 16
Call-in authority = Intra-office
= Local
= Local toll
= National toll
= International toll
= Intra-Centrex
= Incoming Centrex
= Intra-office national toll
= Intra-office international toll
= Intra-centrex local toll
= Intra-centrex national toll
= Intra-centrex international toll
= Intra-office local toll
= Customize call-in authority 1
= Customize call-in authority 2
= Customize call-in authority 3
= Customize call-in authority 4
= Customize call-in authority 5
= Customize call-in authority 6
= Customize call-in authority 7
= Customize call-in authority 8
= Customize call-in authority 9
= Customize call-in authority 10
= Customize call-in authority 11
= Customize call-in authority 12
= Customize call-in authority 13
= Customize call-in authority 14
= Customize call-in authority 15
= Customize call-in authority 16
(Number of results = 1)
那是我的代码:
fichier= open ("Restrictions.txt", "w")
while True:
lign = tn.read_until(b"\n\r")
#print lign
fichier.write(lign)
fichier.close()
程序被阻止。
提前谢谢。