I am running some bash commands via python os.system('/vt -start ./home/mydb ./home/images/image-001-053.png 2>&1 | tee ./ results.txt >/dev/pts/2')
.
This is a command which can be run on terminal with tty=/dev/pts/2
.
After running the command , the output of bash terminal is saved in a file (results.txt
) and later I should read the file. The problem is that after running the command, I need to press keyboard Enter key
manually to run the next command in the same terminal with tty
number 2
, python is not forcing '\n'
to return to command line again.
Do you have any suggestion? How can I add a command which simulates keyboard Enter key
on the terminal?
read
(which requires you to press enter), then you could doecho | read
from bash to get around that.expect
is a more advanced tool for this. – habs Apr 13 '18 at 20:26./vt -start ./home/mydb ./home/images/image-001-053.png 2>&1 | tee ./ results.txt >/dev/pts/2
– sc241 Apr 13 '18 at 21:09>/dev/pts/2
and the other>/dev/pts/18
. One acts as client side – sc241 Apr 13 '18 at 21:11subprocess.call()
,subprocess.Popen()
orsubprocess.check_output()
. – Jacob Vlijm Apr 13 '18 at 21:15