<tfoot id='Y1kZM'></tfoot>
<legend id='Y1kZM'><style id='Y1kZM'><dir id='Y1kZM'><q id='Y1kZM'></q></dir></style></legend>

<small id='Y1kZM'></small><noframes id='Y1kZM'>

    <bdo id='Y1kZM'></bdo><ul id='Y1kZM'></ul>

      1. <i id='Y1kZM'><tr id='Y1kZM'><dt id='Y1kZM'><q id='Y1kZM'><span id='Y1kZM'><b id='Y1kZM'><form id='Y1kZM'><ins id='Y1kZM'></ins><ul id='Y1kZM'></ul><sub id='Y1kZM'></sub></form><legend id='Y1kZM'></legend><bdo id='Y1kZM'><pre id='Y1kZM'><center id='Y1kZM'></center></pre></bdo></b><th id='Y1kZM'></th></span></q></dt></tr></i><div id='Y1kZM'><tfoot id='Y1kZM'></tfoot><dl id='Y1kZM'><fieldset id='Y1kZM'></fieldset></dl></div>

        查找带有子进程的命令不适用于 Shell=True

        时间:2023-08-30
        <i id='VrUr5'><tr id='VrUr5'><dt id='VrUr5'><q id='VrUr5'><span id='VrUr5'><b id='VrUr5'><form id='VrUr5'><ins id='VrUr5'></ins><ul id='VrUr5'></ul><sub id='VrUr5'></sub></form><legend id='VrUr5'></legend><bdo id='VrUr5'><pre id='VrUr5'><center id='VrUr5'></center></pre></bdo></b><th id='VrUr5'></th></span></q></dt></tr></i><div id='VrUr5'><tfoot id='VrUr5'></tfoot><dl id='VrUr5'><fieldset id='VrUr5'></fieldset></dl></div>
        <tfoot id='VrUr5'></tfoot>

          • <bdo id='VrUr5'></bdo><ul id='VrUr5'></ul>
          • <small id='VrUr5'></small><noframes id='VrUr5'>

            <legend id='VrUr5'><style id='VrUr5'><dir id='VrUr5'><q id='VrUr5'></q></dir></style></legend>
              <tbody id='VrUr5'></tbody>

                • 本文介绍了查找带有子进程的命令不适用于 Shell=True的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的代码中有以下几行.我嵌入了一条短线,用于获取超过 10 分钟的文件列表.我的子流程失败了,几乎没有错误.当我给 Shell=True 时它似乎有效,但我读到使用该选项非常冒险,而且我对 Python 很陌生,不想弄乱我不理解的东西.我曾尝试在 find 语句中和周围更改引号,但这对我没有帮助.您能否建议我如何使用 find 命令获取文件列表.我用这些 find 和 subprocess 组合研究了其他问题,我没有找到任何通配符目录匹配项.我找不到解决方案.

                  I have below lines in my code. I have embedded a short a line which fetches the list of files that are older than 10 mins. My sub process have been failing with few errors. It seems to work when I give Shell=True, but I read that it is a very risky to use that option and I am very new to the Python, Don't want to mess up with something I am not understanding. I have tried changing quotes with in and around that find statement, but its not helping me. can you please suggest how could I get the list of files using find command. I have looked into other questions with these find and subprocess combinations, I did not find any wildcard directory matches. I could not find solution for this.

                  cmd = 'find /myapp/uat/aws/6.3/domains/*/appnodes/*/*/log/bwappnode.log -type f -mmin +10'
                  
                   apps_in_proc = subprocess.Popen(cmd,stdout=subprocess.PIPE, universal_newlines=True)
                  

                  推荐答案

                  如果它与 shell=True 一起工作,并且不是没有,这意味着模式是用 shell=True 扩展的.

                  if it works with shell=True, and not without, that means that the pattern is expanded with shell=True.

                  要模拟这种行为,只需使用 glob.glob 并像这样编写命令参数列表:

                  To emulate this behaviour just use glob.glob and compose your command argument list like this:

                  cmd = ['find'] + glob.glob('/myapp/uat/aws/6.3/domains/*/appnodes/*/*/log/bwappnode.log') + ['-type','f','-mmin','+10']
                  

                  在纯python中可以很容易地编写:

                  Which could be written very easily in pure python:

                  import glob,os,time
                  current = time.time()
                  old_files = [x for x in glob.glob("/myapp/uat/aws/6.3/domains/*/appnodes/*/*/log/bwappnode.log") if current - os.path.getmtime(x) > 600]
                  

                  这篇关于查找带有子进程的命令不适用于 Shell=True的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:RegExp:删除字符串中可以包含其他句点的最后一个句点(挖掘输出) 下一篇:在 Python 字典中查找和替换值

                  相关文章

                • <small id='cQayR'></small><noframes id='cQayR'>

                • <tfoot id='cQayR'></tfoot>
                  <i id='cQayR'><tr id='cQayR'><dt id='cQayR'><q id='cQayR'><span id='cQayR'><b id='cQayR'><form id='cQayR'><ins id='cQayR'></ins><ul id='cQayR'></ul><sub id='cQayR'></sub></form><legend id='cQayR'></legend><bdo id='cQayR'><pre id='cQayR'><center id='cQayR'></center></pre></bdo></b><th id='cQayR'></th></span></q></dt></tr></i><div id='cQayR'><tfoot id='cQayR'></tfoot><dl id='cQayR'><fieldset id='cQayR'></fieldset></dl></div>

                  <legend id='cQayR'><style id='cQayR'><dir id='cQayR'><q id='cQayR'></q></dir></style></legend>

                    <bdo id='cQayR'></bdo><ul id='cQayR'></ul>