Accessing ad2*/ser2sock from Terminal

General Discussion

Accessing ad2*/ser2sock from Terminal

Postby davidk » Sat Mar 07, 2015 5:00 pm

If you want to interact with the ad2* over ser2sock using Terminal on Mac OS X, you can use "nc" or "telnet", but things don't look quite right if you use the default settings. I wrote the following script to avoid the issues I was seeing:

Code: Select all
#!/bin/sh

HOSTNAME=ad2pi.local
PORTNUMBER=10000

SAVED_STTY=`stty -g`
stty -icanon -icrnl inlcr -echoctl -echo echonl
nc $HOSTNAME $PORTNUMBER
stty $SAVED_STTY


Save this to "ad2pi.sh", then mark it executable ("chmod a+x ad2pi.sh"), and run it ("./ad2pi.sh").

This script assumes your ser2sock is listening on port 10000 on a host named "ad2pi.local"; update the values as needed.

Explanation:

This sequence of commands first saves the current TTY state so that it can restore it later, and then overrides the TTY handling of echoing and newlines. Next, the "nc" command is used to connect to the remote socket. Finally, after "nc" has exited (use Control-C to exit), the TTY state is restored.
davidk
newt
newt
 
Posts: 2
Joined: Sat Mar 07, 2015 3:39 pm

Re: Accessing ad2*/ser2sock from Terminal

Postby Scott » Mon Mar 09, 2015 12:17 pm

Cool stuff, thanks!
Scott
Expert Nut
Expert Nut
 
Posts: 118
Joined: Thu Dec 12, 2013 11:17 am


Return to General

Who is online

Users browsing this forum: No registered users and 39 guests

cron