我有shell腳本,它在終端執行時輸出一些文本結果。閱讀shell腳本導致python
我能夠執行從Python腳本,shellscipt,但我不能存儲shell腳本導致成蟒蛇
我的python腳本:
import subprocess
#result = subprocess.call(['/root/Desktop/karim/software/cherrypicker1.01/cherryP.sh'],shell = True) This yields result 0
subprocess.call(['/root/Desktop/karim/software/cherrypicker1.01/cherryP.sh'],shell = True)
print "REsult is : "
print result
cherryP.sh
./cherrypicker.sh input.txt
#for line in $(cat input.txt.responses); do echo "$line" ; done
DONE=false
until $DONE
do
read line || DONE=true
echo $line # this will echo the result which I want to use in python script
done < input.txt.responses
我在做什麼錯,或者其他合理的解決方案是什麼?
修訂cherryP.py
import subprocess
result = subprocess.check_output(['/root/Desktop/karim/software/cherrypicker1.01/cherryP.sh'], shell = True)
print result
如果你想讀在bash文件的最後一行,您可以用'尾-n 1 input.txt.responses' – 2014-09-19 08:11:47