Created
December 12, 2015 12:46
-
-
Save mcschroeder/afffb2e7f6ab007d8a6f to your computer and use it in GitHub Desktop.
Create virtual serial ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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