python - AWS Greengrass subprocess commands not working -


i running greengrass on raspberry pi 3 device, ran issues raspberry pi doesnt resolve dns routers , workaround run following python script:

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 off"         return false     print "internet 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" 

the above code works fine when run python as-is command line, crashes greengrass core when run through via lambda function.

i following error in crash.log (all of in 1 go):

/bin/sh: 1: ping: not found /bin/sh: 1: ping: not found /bin/sh: 1: ping: not found /bin/sh: 1: ping: not found 

the script calling module provided above goes like:

def check_internet():     if net_check.internet_on() false:         net_check.fire_dns_corrector()  check_internet() 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -