I am trying to test a particular chat program by sending a series of commands and capturing the output.
How can I pass:
sleep 2 echo test sleep 2 echo test1 I have tried this:
(sleep 2; echo test; sleep 2; echo test1) | python3 test.py but it just prints the first part while for the second I get nothing. It enters into an endless loop instead.
the python program's code is:
import sys, select while True: socket_list = [sys.stdin] read_sockets, write_sockets, error_sockets = select.select(socket_list, [], []) for sock in read_sockets: message = sys.stdin.readline() sys.stdout.write("> %s: ") sys.stdout.flush() I should mentioned that this is not the complete program but it is the part where it helps recreate the exact same effect.
{ sleep 2; echo test; sleep 2; echo test1 }and maybe redirect it to python instead of pipe?date +%s; (sleep 2; echo test; sleep 2; echo test1) | perl -pe '$_=time()." ".$_'shows bothteststrings and the two-second delays for me.