grep No such file or directory with envoy.run
<p>I try to build script that execute some grep search in my logs and print the results.
I try to use Envoy because is more easy than subprocess but when I execute grep command it gives me back an error of no such file o directory.</p>

<p>The dir structure is easy:</p>

<ul>
<li>. # root of script</li>
<li>test.py # script file</li>
<li>web_logs/log/ # dir that contains log to search in</li>
</ul>

<p>My test.py is easy:</p>

<pre><code>import envoy

def test(value):

   search = "grep 'cv="+str(value)+"' ./web_logs/log/log_*"
   print(search) #check of the search string
   r = envoy.run(search)
   print(r.status_code, r.std_out, r.std_err)#check of the command
   response = r.std_out

if __name__ == "__main__":
   test(2)
</code></pre>

<p>The output is:</p>

<pre><code>grep 'cv=2' ./web_logs/log/log_*
(2, '', 'grep: ./web_logs/log/log_*: No such file or directory\n')
</code></pre>

<p>If i run the same command:</p>

<pre><code>grep 'cv=2' ./web_logs/log/log_*
</code></pre>

<p>I can find the occurrence of the string "cv=2" in the log files.</p>

<p>Where is the error?</p>

<p><strong>Update after the answers</strong>
The problem is in using of * that envoy cannot explode without use of glob module so I using the subprocess as it is and I try to study better the using of glob module to improve envoy.</p>

<p>The new code I used is:</p>

<pre><code>import subprocess

def test(value):

   search = "grep 'cv="+str(value)+"' ./web_logs/log/log_*"
   print(search) #check of the search string
   proc = subprocess.check_output(search, shell=True)
   print proc.split('\n')

if __name__ == "__main__":
   test(2)
</code></pre>