mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
bidir_cmd_herlper.sh: Bidirectional command helper by socat. bidir_cmd_helper.py: Bidirectional command helper by python and netcat. pexpect-ping.py, pexpect-pong.py: Scripts for throwing Ping-Pong between cross-connected tios.
22 lines
443 B
Python
Executable file
22 lines
443 B
Python
Executable file
#!/usr/bin/python3
|
|
# In MSYS2, use /mingw64/bin/python3
|
|
#
|
|
# wait for a "Ping" and Send a "Pong"
|
|
# Repeat this process.
|
|
#
|
|
|
|
import pexpect
|
|
from pexpect import popen_spawn
|
|
|
|
child = pexpect.popen_spawn.PopenSpawn("nc -UN /tmp/tio-socket1")
|
|
|
|
cnt = 0
|
|
while True:
|
|
try:
|
|
child.expect(r'Ping \d+[\r\n]+', timeout = 10)
|
|
child.sendline(f"Pong {cnt:d}")
|
|
cnt += 1
|
|
except Exception as e:
|
|
print(type(e))
|
|
break
|
|
|