I want to read output line by line
below is my bash code (meta.sh)
#!/bin/bash
echo "hello!"
read -p "Continue?(y/n)"
[ "$REPLY" == "y" ] || exit
echo "lol"
below is my subprocess code (test.py)
import subprocess
def create_subprocess(Command):
proc = subprocess.Popen(
Command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=1
)
return proc
Command = "/root/Desktop/meta.sh"
proc = create_subprocess(Command)
while True:
line = proc.stdout.readline()
if not line: break
print line.strip()
now when i run "python test.py" it shows
hello!
now when I press y and press enter then it shows
Continue?(y/n)
lol
what ideally it should show is this
hello!
Continue?(y/n)
now when I press y and press enter then it should show
lol