Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
返回非零退出状态3 python2.7子流程检查\u输出_Python_Linux_Python 2.7_Curl_Subprocess - Fatal编程技术网

返回非零退出状态3 python2.7子流程检查\u输出

返回非零退出状态3 python2.7子流程检查\u输出,python,linux,python-2.7,curl,subprocess,Python,Linux,Python 2.7,Curl,Subprocess,我已经编写了一些python代码,它进行了一个执行curl命令的子进程调用,但是我得到了一个错误command'['sh','/tests/curlhttp.sh','http://www.bbc.co.uk“,“80']”返回非零退出状态3我也尝试过通过linux设备上的终端运行该命令,这似乎没有问题。这是我的python脚本 def RunCURL(command): result = [] //I get an error when running this out

我已经编写了一些python代码,它进行了一个执行curl命令的子进程调用,但是我得到了一个错误
command'['sh','/tests/curlhttp.sh','http://www.bbc.co.uk“,“80']”返回非零退出状态3
我也尝试过通过linux设备上的终端运行该命令,这似乎没有问题。这是我的python脚本

def RunCURL(command):
    result = []
    //I get an error when running this
    output = check_output(command.split(" "), stderr=subprocess.STDOUT)
    print output
    # loop through and create a list of lists
    for line in output.splitlines():
        if "=" in line and "time_total" not in line:
            sublist = line.split("=")[0].rstrip().lstrip()
            print sublist + " hello this is curl"
            result.append(sublist)
    return result
下面是我正在尝试执行的curl脚本:

    #!/bin/bash
curl -w '\ncontent_type=%{content_type}\nfilename_effective=%{filename_effective}\nftp_entry_path=%{ftp_entry_path}\nhttp_code=%{http_code}\nhttp_connect=%{http_connect}\nlocal_ip=%{local_ip}\nlocal_port=%{local_port}\nnum_connects=%{num_connects}\nnum_redirects=%{num_redirects}\nredirect_url=%{redirect_url}\nremote_ip=%{remote_ip}\nremote_port=%{remote_port}\nsize_download=%{size_download}\nsize_header=%{size_header}\nsize_request=%{size_request}\nsize_upload=%{size_upload}\nspeed_download=%{speed_download}\nspeed_upload=%{speed_upload}\nssl_verify_result=%{ssl_verify_result}\ntime_appconnect=%{time_appconnect}\ntime_connect=%{time_connect}\ntime_namelookup=%{time_namelookup}\ntime_pretransfer=%{time_pretransfer}\ntime_redirect=%{time_redirect}\ntime_starttransfer=%{time_starttransfer}\ntime_total=%{time_total}\nurl_effective=%{url_effective}\n\n' -o /dev/null -s $1:$2
我从这个博客中获取了这个curl脚本,只更改了脚本上的地址字段以接受url和端口号:

这就是我在运行从博客本身直接复制到终端的curl脚本时得到的结果

content_type=text/html; charset=UTF-8
filename_effective=/dev/null
ftp_entry_path=
http_code=302
http_connect=000
local_ip=10.250.8.99
local_port=60839
num_connects=1
num_redirects=0
redirect_url=https://www.google.co.uk/?gfe_rd=cr&ei=_7gdWOrCLrH38Af1qoKIBw
remote_ip=216.58.204.36
remote_port=443
size_download=262
size_header=258
size_request=78
size_upload=0
speed_download=3535.000
speed_upload=0.000
ssl_verify_result=0
time_appconnect=0.062
time_connect=0.013
time_namelookup=0.001
time_pretransfer=0.062
time_redirect=0.000
time_starttransfer=0.074
time_total=0.074
url_effective=https://www.google.com/
当我把这个脚本放到一个文件中时,我得到了这个

content_type=
filename_effective=/dev/null
ftp_entry_path=
http_code=000
http_connect=000
local_ip=
local_port=0
num_connects=0
num_redirects=0
redirect_url=
remote_ip=
remote_port=0
size_download=0
size_header=0
size_request=0
size_upload=0
speed_download=0.000
speed_upload=0.000
ssl_verify_result=0
time_appconnect=0.000
time_connect=0.000
time_namelookup=0.000
time_pretransfer=0.000
time_redirect=0.000
time_starttransfer=0.000
time_total=0.000
url_effective=https://www.google.com/

看起来像3意味着你的URL格式错误。当您在Python之外运行它时,它能工作吗?

查看它看起来像3,这意味着您的URL格式错误。当您在Python之外运行它时,它工作吗?

我从博客中复制并粘贴了curl脚本,然后运行它,它工作了。然而,当我复制并粘贴到一个shell文件中时,除了标签之外,它似乎没有给我任何信息。我已经编辑了我的文章,将预期的输出与我从名为sh commands的文件中放置的curl脚本中获得的输出进行对比。我从博客中复制并粘贴了curl脚本,然后运行了它,它成功了。然而,当我复制并粘贴到一个shell文件中时,除了标签之外,它似乎没有给我任何信息。我已经编辑了我的帖子,将预期的输出与我从名为sh命令的文件中放置的curl脚本中获得的输出进行对比