Friday, February 15, 2019

SSH to all of the serial ports

This is just a quick-and-dirty script for logging into every serial port on an Opengear box, one in each tab of a MacOS terminal.

Used it just recently because I couldn't remember where a device console was connected.

Don't change mouse focus while it's running: It'll wind up dumping keystrokes into the wrong window.

for i in $(seq 48)
  port=$(expr 3000 + $i)
  sshcmd="ssh -p $port terminalserver"
  osascript \
    -e 'tell application "Terminal" to activate' \
    -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
    -e "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"$sshcmd\"" \
    -e "tell application \"System Events\" to tell process \"Terminal\" to key code 36"

Leaving it here in case somebody (probably me) finds it useful in the future.

1 comment:

  1. Play online casino site for real money | Lucky Club
    No deposit bonuses · No deposit bonus · Use our No Deposit Bonus code · Enjoy the best casino online with us · Deposit bonus up to $10 · Play with free chips or real money