Skip to content

Instantly share code, notes, and snippets.

@TylerOderkirk
Created June 14, 2015 17:22
Show Gist options
  • Save TylerOderkirk/d2f9d29d4989d8b217ed to your computer and use it in GitHub Desktop.
Save TylerOderkirk/d2f9d29d4989d8b217ed to your computer and use it in GitHub Desktop.
[dirt simple comms] make a SLIP connection over a socat-provided pty which is conected to https://gist.github.com/TylerOderkirk/c8510292cc86648074b5
#!/bin/bash
socat -ddd -ddd PTY,raw,echo=0 "EXEC:'python /home/tz/proj/dsc/stdinout_tofrom_named_pipe.py that',pty,raw,echo=0" &
SOCAT_PID1=${!}
echo
read -p 'Enter PTY number (eg "12"): ' PTY1
sudo slattach -dv -p slip /dev/pts/${PTY1} &
SLATTACH_PID1=${!}
echo
read -p 'Enter interface name (eg "sl0"): ' IFACE1
sudo ifconfig ${IFACE1} 192.168.0.1 pointopoint 192.168.0.2 up
sudo route add -host 192.168.0.2 dev ${IFACE1}
socat -ddd -ddd PTY,raw,echo=0 "EXEC:'python /home/tz/proj/dsc/stdinout_tofrom_named_pipe.py other',pty,raw,echo=0" &
SOCAT_PID2=${!}
echo
read -p 'Enter PTY number (eg "12"): ' PTY2
sudo slattach -dv -p slip /dev/pts/${PTY2} &
SLATTACH_PID2=${!}
echo
read -p 'Enter interface name (eg "sl0"): ' IFACE2
sudo ifconfig ${IFACE2} 192.168.0.2 pointopoint 192.168.0.1 up
sudo route add -host 192.168.0.1 dev ${IFACE2}
echo "slattach pids: " ${SLATTACH_PID1} ${SLATTACH_PID2}
echo "socat pids: " ${SOCAT_PID1} ${SOCAT_PID2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment