我的树莓派已连接到网络中,我必须在该网络上运行 python 脚本。该Python脚本存储在本地。我正在将命令写为
type <Python Script> | plink <user>@192.168.0.10 -pw <password> 'python - OFF CSM1'
但是它给了我错误
bash: line 1: python3 - OFF CSM1: command not found
从 Windows 命令提示符执行此操作的方法是什么?
将以下内容视为 python 脚本
args.py
import sys; print("First argument is "+sys.argv[1]+" and second argument is "+sys.argv[2])
并在 Windows 中执行以下命令(在我的例子中是在 powershell 中)
type .\args.py | plink <theuser>@<thehostname> -pw <thepassword> 'python - FOO BAR'
你得到了预期的结果
First argument is FOO and second argument is BAR
无论带引号还是不带引号,都可以使用单引号或双引号
type .\args.py | plink <theuser>@<thehostname> -pw <thepassword> 'python - FOO BAR'
type .\args.py | plink <theuser>@<thehostname> -pw <thepassword> "python - FOO BAR"
type .\args.py | plink <theuser>@<thehostname> -pw <thepassword> python - FOO BAR
所有命令均已在 Windows 10 Enterprise 22H2 上使用 powershell 5.1.19041.4170 和 7.4.2 进行验证,在本地网络上连接到在 Raspberry Pi OS bullseye 内运行 Python 3.9.2 的 Raspberry PI。
总之,您的命令完全没问题,问题可能在于您的答案未指定什么,即“