问题描述
我正在尝试使用 Fabric 在 VPS 服务器上运行我的 python 脚本。
我编写了一个有效的代码,但我不知道我的脚本是否真的在 VPS 上运行。为了检查这一点,我创建了一个变量“x”来打印机器的 IP 地址
import socket
from fabric import Connection,task
c = Connection(host= "myipadresse",user= "root",connect_kwargs={"password": "mypassword"})
def process_list(c):
x = socket.gethostbyname(socket.gethostname())
print(x)
return c.run(process_list(c))
process_list(c)
print(process_list(c))
通常,当我在我的机器上打印(x)时:
Output : 192.168.111.1
现在,当我运行我向您展示的代码时,正如我所知,它应该向我打印 VPS 的 ip 而不是 192.168.111.1
Output again : 192.168.111.1
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)