简体   繁体   English

在远程linux主机上运行带有参数的python脚本

[英]run python script with arguments on a remote linux host

I have this python script that I'm trying to run on a remote host. 我有一个要在远程主机上运行的python脚本。 However, the script requires two arguments. 但是,脚本需要两个参数。 For example, python script.py --port 4000 --service status 例如python script.py --port 4000-服务状态

Now when I run the script locally on the machine it works fine. 现在,当我在计算机上本地运行脚本时,它可以正常运行。 How can I run this same script on a remote linux machine. 如何在远程linux机器上运行相同的脚本。 I've tried ssh user@remotehost python script.py --port 4000 --service status This doesn't work. 我已经尝试过ssh user @ remotehost python script.py --port 4000 --service status这不起作用。 The arguments are not passed in. 参数未传递。

Thank you 谢谢

You should use the following - 您应该使用以下内容-

ssh user@remotehost "python script.py --port 4000 --service status"

Please notice the " double quotes, it has to be double quotes. 请注意"双引号,它必须是双引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM