hcitool lescan subprocess python do not produce output -


i have problem sub-process code. subprocess.popen() works fine when try read output through stdout.read() there no value read.

**import os import signal import subprocess import threading import sys import commands  print commands.getoutput("hcitool dev") print 'down' commands.getoutput('hciconfig hci1 down') print 'up' commands.getoutput('hciconfig hci1 up') commands.getoutput('killall hcitool') stop = false ping = subprocess.call('hcitool lescan', shell = false, stdout=subprocess.pipe,executable='/bin/bash') in ping.stdout:     print  def kill():     global stop     stop = true     os.kill(ping.pid, signal.sigterm)  threading.timer(5, kill).start()  #while not stop: #   print 'now in while not loop' #   sys.stdout.write(ping.stdout.read(1))  print 'trying print stdout' out, err = ping.communicate() print "out",out  #result = out.decode()  print "result : ",result** 

this code works fine when change hcitool lescan ping www.google.com, , produces output when try hcitool lescan either hangs forever or produces no output. appreciated!

any of above answers didn't work me. hung in forever scan of hcitool. wrote shell script , called python code. working fine me , reading output file "result.txt".

hcitool lescan>result.txt &   sleep 5   pkill --signal sigint hcitool 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -