Skip to content

Instantly share code, notes, and snippets.

@nlm
Created January 20, 2017 14:47
Show Gist options
  • Save nlm/01dd9cd614e528c2213cf379c99ddf26 to your computer and use it in GitHub Desktop.
Save nlm/01dd9cd614e528c2213cf379c99ddf26 to your computer and use it in GitHub Desktop.
Login Shell to automatically connect to serial port via ssh
#!/bin/bash
name="$(basename $0)"
echo "$name"
if [[ "$name" =~ serialsh-(tty[a-zA-Z0-9]+)(-([0-9]+))? ]]; then
tty="${BASH_REMATCH[1]}"
speed="${BASH_REMATCH[3]}"
exec screen -dR "serialsh-${tty}" "/dev/${tty}" $speed
else
echo "usage: $0"
echo "symlink this file as serialsh-tty0 to access tty0"
echo "symlink this file as serialsh-ttyUSB0-115200 to"
echo " access /dev/ttyUSB0 at 115200 bauds"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment