【问题标题】:subprocess return None what does that mean for my fuzzersubprocess return None 这对我的模糊器意味着什么
【发布时间】:2020-04-27 08:30:01
【问题描述】:

在学校我必须制作一个模糊器,我使用 Charle Miller 来对 pdf 文件进行引信。我想检查应用程序的失败次数。当我这样做时

result = process.communicate()
    print(result)

它多次打印 (None,None) 是什么意思?

【问题讨论】:

    标签: python subprocess output fuzzer


    【解决方案1】:

    表示创建subprocess.Popen对象时,没有指定stdout=PIPEstderr=PIPE

    Popen.communicate(input=None, timeout=None)

    与进程交互:将数据发送到标准输入。从标准输出和标准错误读取数据 [...]

    communicate() 返回一个元组(stdout_data,stderr_data)。 [...]

    注意,如果你想向进程的标准输入发送数据,你需要用stdin=PIPE创建Popen对象。同样,要在结果元组中获得除None 以外的任何内容,您需要提供stdout=PIPE 和/或stderr=PIPE [emph.也添加了]。

    ——subprocess - Subprocess Management - Python 3 Documentation

    例如:

    import subprocess
    apples_only = subprocess.Popen(
        ["grep", "apple"], 
        stdin=subprocess.PIPE, 
        stdout=subprocess.PIPE,
    )
    out, err = apples_only.communicate(b"pear\napple\nbanana\n")
    
    print((out, err))
    # (b'apple\n', None)  # did not say stderr=PIPE so it's None.
    

    【讨论】:

    • 嗯,好吧,我想我明白了,但是通过使用它,我怎么知道我的模糊器是否运行良好?
    • 不知道,我不知道“Charlie Miller”是谁/什么,或者“引信”PDF,你没有提到你是使用单独的程序作为模糊器还是只是通过 Python 等控制一个。
    • 是的,哈哈,我会阅读更多关于子进程的信息来尝试解决这个问题
    猜你喜欢
    • 2023-01-03
    • 2018-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多