首页后端开发Pythonudp可以远程执行cmd命令吗

udp可以远程执行cmd命令吗

时间2023-06-04 22:06:01发布访客分类Python浏览158
导读:udp可以远程执行cmd命令吗?你可以使用python的pexcpct包通过ssh调用远程服务器指令:import pxsshimport getpasstry:s = pxssh.pxssh( hostname = raw_input('...

udp可以远程执行cmd命令吗?

你可以使用python的pexcpct包通过ssh调用远程服务器指令:

import pxssh

import getpass

try:

s = pxssh.pxssh()

hostname = raw_input('hostname: ')

username = raw_input('username: ')

password = getpass.getpass('password: ')

s.login (hostname, username, password)

s.sendline ('uptime') # run a command

s.prompt() # match the prompt

print s.before # print everything before the propt.

s.sendline ('ls -l')

s.prompt()

print s.before

s.sendline ('df')

s.prompt()

print s.before

s.logout()

except pxssh.ExceptionPxssh, e:

print "pxssh failed on login."

print str(e)

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: udp可以远程执行cmd命令吗
本文地址: https://pptw.com/jishu/61661.html
为什么python中randomrandint无法运行 如何用python快速读取几G以上的大文件

游客 回复需填写必要信息