python 操控远程计算机,在另一台计算机上运行的python脚本的远程控制功能

这听起来像是Pyro4 包的工作。这是一个基于他们的“简单示例”的示例,并带有一些额外的代码来自动启动名称服务器并通过网络进行监听。

首先在每台机器上使用以下命令来安装Pyro4:

pip install pyro4

在服务器上,将该脚本另存为server.py,然后通过python server.py以下命令在终端窗口中运行:

# saved as server.py

import Pyro4, Pyro4.naming

import socket, threading

# Define an object that will be accessible over the network.

# This is where all your code should go...

@Pyro4.expose

class MessageServer(object):

def show_message(self, msg):

print("Message received: {}".format(msg))

# Start a Pyro nameserver and daemon (server process) that are accessible

# over the network. This has security risks; see

# https://pyro4.readthedocs.io/en/stable/security.html

hostname = socket.gethostname()

ns_thread = threading.Thread(

target=Pyro4.naming.startNSloop, kwargs={&#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值