python subprocess.check\u调用未正确解析

python subprocess.check\u调用未正确解析,python,Python,各位, 我试图从这段代码中调用一个可执行文件,但由于某种原因,它不能正常工作(Python2.6) 输出: {:message=>"Missing required -s flag. What package source did you want?", :level=>:warn, :timestamp=>"2013-12-05T17:37:29. %6N+0000"} {:message=>"Missing required -t flag. What packa

各位, 我试图从这段代码中调用一个可执行文件,但由于某种原因,它不能正常工作(Python2.6)

输出:

{:message=>"Missing required -s flag. What package source did you want?", :level=>:warn, :timestamp=>"2013-12-05T17:37:29.   %6N+0000"}
{:message=>"Missing required -t flag. What package output did you want?", :level=>:warn, :timestamp=>"2013-12-05T17:37:29.   %6N+0000"}
{:message=>"No parameters given. You need to pass additional command arguments so that I know what you want to build packages from. For example, for '-s dir' you would pass a list of files and directories. For '-s gem' you would pass a one or more gems to package from. As a full example, this will make an rpm of the 'json' rubygem: `fpm -s gem -t rpm json`", :level=>:warn, :timestamp=>"2013-12-05T17:37:29.   %6N+0000"}

subprocess.CalledProcessError: Command '['fpm', '-s', 'dir', '-t', 'rpm', '-n', 'name', '-v', 'rpmversion', '--prefix=/opt/', '--rpm-auto-add-directories', 'target']' returned non-zero exit status 1
Build step 'Execute shell' marked build as failure

从cli运行相同的命令非常有效。有什么建议吗?

如果不需要,最好不要使用
shell=True
(因为与用户提供的参数一起使用时可能存在安全风险--请参阅)。在这种情况下,您可以使用

subprocess.check_call(
 ['fpm', '-s', 'dir', '-t', 'rpm', '-n', 'name', '-v', 'rpmversion',
  '--prefix=/opt/', '--rpm-auto-add-directories', 'target'])

shell=True
时,应传递一个字符串作为第一个参数:

subprocess.check_call(
    'fpm -s dir -t rpm -n name -v rpmversion --prefix=/opt/ --rpm-auto-add-directories target', shell=True)

如果不需要,最好不要使用
shell=True
(因为与用户提供的参数一起使用时可能存在安全风险--请参阅)。在这种情况下,您可以使用

subprocess.check_call(
 ['fpm', '-s', 'dir', '-t', 'rpm', '-n', 'name', '-v', 'rpmversion',
  '--prefix=/opt/', '--rpm-auto-add-directories', 'target'])

shell=True
时,应传递一个字符串作为第一个参数:

subprocess.check_call(
    'fpm -s dir -t rpm -n name -v rpmversion --prefix=/opt/ --rpm-auto-add-directories target', shell=True)