title: AWS Greengrass subprocess commands not working
body: <p>I am running greengrass on my Raspberry Pi 3 device, I ran into issues where Raspberry Pi doesnt resolve DNS properly with some routers and to do a workaround I run the following python script:</p>
  
  <pre><code>import urllib2
  import subprocess
  import platform
  import time
  
  def internet_on():
      try:
          output = subprocess.check_output("ping -{} 1 {}".format('n' if platform.system().lower()=="windows" else 'c', "a2jcwnhq2encoj.iot.us-east-1.amazonaws.com"), shell=True)
  
      except Exception, e:
          print "internet is off"
          return False
      print "internet is on"
      return True
  
  def fire_dns_corrector():
      if platform.system().lower() != "windows":
          print "running resolver"
          bash_command = "bash /home/pi/nameresolution.sh"
          print bash_command
          subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
          time.sleep(5)
      else:
          print "cannot resolve internet while running windows"
  </code></pre>
  
  <p>The above code works fine when I run the python as-is from a command line, however crashes the greengrass core when run through it via a Lambda function.</p>
  
  <p>I get the following error in crash.log (all of it in one go):</p>
  
  <pre><code>/bin/sh: 1: ping: not found
  /bin/sh: 1: ping: not found
  /bin/sh: 1: ping: not found
  /bin/sh: 1: ping: not found
  </code></pre>
  
  <p>The script calling the module I provided above goes something like:</p>
  
  <pre><code>def check_internet():
      if net_check.internet_on() is False:
          net_check.fire_dns_corrector()
  
  check_internet()
  </code></pre>