我试图在Pi上通过ssh执行python脚本。我已经设置了Priv/Pub键,并在主机上使用python脚本执行它们:
subprocess.run('ssh -p 2222 john@<IP_of_Pi> python3 /home/john/test.py', shell=True)
我正在尝试使用autogui自动化一些事情。我的基本脚本是这样的
import pyautogui as aut
aut.PAUSE = 1
aut.keyDown('ctrl')
aut.keyDown('alt')
aut.press('t')
aut.keyUp('alt')
aut.keyUp('ctrl')
aut.typewrite(['f','i','r','e','f','o','x','enter'])
aut.hotkey('alt','d')
aut.typewrite(['d','u','c','k','d','u','c','k','g','o','.','c','o','m','enter'])
我的问题是我执行的所有命令都在本地主机上运行。如果我使用其他自动化框架,比如Selenium,也是如此。我打开的每个浏览器不是在我的Pi上启动的,而是在我的主机上启动的。你知道吗
我尝试过对子流程的一些修改,比如
subprocess.run(['ssh','-p','2222 ','john@<IP_of_Pi>', 'python3', /home/john/test.py'])
subprocess.run(['ssh','-p','2222 ','john@<IP_of_Pi>', 'python3', /home/john/test.py'],shell=True,stdout=subprocess.PIPE)
subprocess.Popen(['ssh','-p','2222 ','john@<IP_of_Pi>', 'python3', /home/john/test.py'])
...
如果我在shell中执行test.py
,浏览器仍然在我的主机上打开,我可以重新解释错误。你知道吗
为了以防万一,我的远程服务器(Pi)上的ssh\u配置:
Host *
# ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# IdentityFile ~/.ssh/id_ecdsa
# IdentityFile ~/.ssh/id_ed25519
# Port 22
# Protocol 2
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
# RekeyLimit 1G 1h
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
目前没有回答
相关问题 更多 >
编程相关推荐