4 ms·
I tend to agree. I am just finishing up a tool I'm using to automate a bunch of interactions I have with the 4 USB UARTs on my desk and I ended up going with ex
by prussian 6y ago
I tend to agree. I am just finishing up a tool I'm using to automate a bunch of interactions I have with the 4 USB UARTs on my desk and I ended up going with expect. If I knew about pexpect I would have probably used that.
However, since I did use expect and spent some time learning Tcl, I actually did appreciate one useful thing about it. It's very easy for me to in-line Tcl code into, say, a configuration, parse it with the help of `[info complete]`, attach it to a list and then expand that list `{*}$some_list` as an argument to `expect` or `interact`. I can now have UART specific macros that are bound to keystrokes like Ctrl-t x. Sure I could do something like that in python, but it probably wouldn't be as clear-cut as:
# Fix terminal row/col height for less, vi, etc
# type Ctrl-t r
bind[r] = {
# depends on xterm size info, may not be universal
send "\{ "
send {old=$(stty -g);}
send {stty raw -echo min 0 time 5;}
send {printf '\033[18t' > /dev/tty;}
send {IFS=';t' read -r _ rows cols _ < /dev/tty;}
send {stty "$old";}
send {stty cols "$cols" rows "$rows";}
send {unset old cols rows;}
send {shopt -s checkwinsize;}
send {clear;}
send " \}\r"
}
- kanox 6y agoIf you want to resize the remote terminal it might be easier to determine the size locally with an ioctl and only execute "stty cols/rows" remotely. It might also help to export the local TERM value remotely because it's not otherwise passed through a serial port.
- prussian 6y agoThanks to you and the other comment under mine, I revised my snippet. I use to just copy/paste it into screen or tio, but now that I have this tool[1] I don't need to. You're absolutely right I could get the terminal size with tools like resize locally and I probably should set TERM to match. [1] the tool if anyone is interested: https://gist.github.com/adedomin/7e615405a2275b01dbae35521161ba87 https://gist.github.com/adedomin/7e615405a2275b01dbae3552116...
- shrubble 6y agoIn a regular shell, would eval 'resize' Do the same thing?