File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -749,6 +749,38 @@ Home:[https://bitbucket.org/jaraco/irc]
749
749
750
750
IRC 是 Internet Relay Chat 的缩写。这是用 Python 封装的第三方库。
751
751
752
+ === 5.3.6 远程控制 ===
753
+
754
+ <h4>telnetlib</h4>
755
+
756
+ 【标准库】
757
+
758
+ 封装 telnet 协议
759
+
760
+ 代码示例——使用 telnet 登录到某个主机并执行简单命令
761
+ <source lang="python">
762
+ import telnetlib
763
+ import getpass
764
+
765
+ host = raw_input("Enter remote host: ")
766
+ user = raw_input("Enter your remote account: ")
767
+ password = getpass.getpass()
768
+
769
+ tn = telnetlib.Telnet(host)
770
+
771
+ tn.read_until("login: ")
772
+ tn.write(user + "\n")
773
+
774
+ if password :
775
+ tn.read_until("Password: ")
776
+ tn.write(password + "\n")
777
+
778
+ tn.write("ls\n")
779
+ tn.write("exit\n")
780
+
781
+ print tn.read_all()
782
+ </source>
783
+
752
784
== 5.4 自定义的应用层 ==
753
785
754
786
<h4>Protocol Buffers</h4>
You can’t perform that action at this time.
0 commit comments