Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create virtual serial ports
#!/bin/sh
if [ -z "$1" ]
then
echo "Usage: $0 name"
exit 1
fi
MASTER=$1
SLAVE=$1_virt
echo "Creating virtual serial port at $(tput bold)$MASTER$(tput sgr0)"
echo "You can listen to the port with $(tput bold)cat $SLAVE$(tput sgr0)"
echo "You can write to the port with $(tput bold)cat > $SLAVE$(tput sgr0)"
GROUP=$(id -gn)
sudo socat -d -d -d -d -lf /tmp/socat pty,link=$MASTER,raw,echo=0,user=$USER,group=$GROUP pty,link=$SLAVE,raw,echo=0,user=$USER,group=$GROUP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.