python - Read feedback from commands? -
i need use command lsmod
check if mod loaded, don't know how read after running it. im using subprocess.popen()
run it. point in right direction appreciated. :d
suppose looking ath
in lsmod
, command be: lsmod | grep ath
using subprocess
:
in [60]: c=subprocess.popen("lsmod",stdout=subprocess.pipe) in [61]: gr=subprocess.popen(["grep" ,"ath"],stdin=c.stdout,stdout=subprocess.pipe) in [62]: print gr.communicate()[0] ath5k 135206 0 ath 19188 1 ath5k mac80211 461261 1 ath5k cfg80211 175574 3 ath5k,ath,mac80211