我在远程机器上有一个python脚本,我想从本地机器上执行.它需要一些参数,如果我要在那台机器上运行它,我就会运行它.
python python_parallel.py --num=10 --ssh=/home/user1/path/file.txt
Run Code Online (Sandbox Code Playgroud)
目前我的本地机器上有一个运行上述脚本的python代码:
from optparse import OptionParser
parser.add_option("-n", "--num", type="int", dest="num_spice",help="Enter the number")
parser.add_option("-s", "--ssh", dest="ssh_txt",help="Enter the path to the text file")
num_spice=options.num_spice
ssh_txt=options.ssh_txt
(options, args) = parser.parse_args()
os.system('ssh user1@10.100.10.201 python /home/user1/path/python_parallel.py --num=%s --ssh=%s' %(num_spice, ssh_txt) )
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法呢?我在这个链接上尝试了解决方案,但它给了我一个错误"ImportError:没有名为ssh的模块"