我正在编写此脚本,该脚本执行一堆命令,其中一个命令是从某个URL下载一些程序包。
以下是我的剧本
#! /usr/bin/env python
#! /usr/bin/env bash
import os
import sys
import subprocess
url = sys.argv[1]
getRpm = "'wget %s' %url"
searchRpm = "rpm -qa|grep sys.*"
execsCmds = [getRpm,searchRpm]
def runCommands(commands=execsCmds):
for cmd in execsCmds:
print "Running Command"
subprocess.call(cmd, shell=True)
runCommands()
当我执行的时候说:
/bin/sh: wget %s: command not found
您构造的行getRpm
可能应该是:
getRpm = 'wget %s' %url
基本上,只需删除多余的双引号。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句