Skip to content

Instantly share code, notes, and snippets.

@mcschroeder
Created December 12, 2015 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcschroeder/afffb2e7f6ab007d8a6f to your computer and use it in GitHub Desktop.
Save mcschroeder/afffb2e7f6ab007d8a6f to your computer and use it in GitHub Desktop.
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