# -*- coding: utf-8 -*-
import telnetlib
Host = '127.0.0.1'
username = 'dinghao'
password = 'dh1020@.'
# 命令提示符,标识着上一条命令执行完成
finish = ':~$ '
tn = telnetlib.Telnet(Host)
tn.read_until('login: ')
tn.write(username + '\n')
tn.read_until('Password: ')
tn.write(password + '\n')
tn.read_until(finish)
tn.write('pwd\n')
tn.read_until(finish)
tn.close()
Python Telnet 示例
最新推荐文章于 2024-05-10 05:44:35 发布