-
Notifications
You must be signed in to change notification settings - Fork 1
/
socat_forward_stick.sh
executable file
·37 lines (34 loc) · 1.21 KB
/
socat_forward_stick.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# http://www.dest-unreach.org/socat/doc/socat-ttyovertcp.txt
# EXAMPLE FOR REMOTE TTY (TTY OVER TCP) USING SOCAT
#
# You have a host with some serial device like a modem or a bluetooth interface
# (modem server)
# You want to make use of this device on a different host. (client)
#
# 1) on the modem server start a process that accepts network connections and
# links them with the serial device /dev/tty0:
#
# $ socat tcp-l:54321,reuseaddr,fork file:/dev/tty0,nonblock,waitlock=/var/run/tty0.lock
#
# 2) on the client start a process that creates a pseudo tty and links it with a
# tcp connection to the modem server:
#
# $ socat pty,link=$HOME/dev/vmodem0,waitslave tcp:modem-server:54321
# socat FILE:/dev/ttyUSB0,nonblock,b9600,raw tcp:localhost:4161
#
echo ""
SOCAT=$(which socat)
# BLOCK_SIZE="-b 64"
BLOCK_SIZE=""
ADDR1="tcp-l:9001,reuseaddr"
ADDR2="FILE:/dev/ttyUSB0,nonblock,b9600,raw"
# ADDR2="FILE:carelink.ttyUSB0,b9600,raw"
# $ socat pty,link=$HOME/dev/vmodem0,waitslave tcp:modem-server:54321
SOCAT_ARGS="-d -d ${BLOCK_SIZE} ${ADDR1} ${ADDR2}"
echo "$SOCAT $SOCAT_ARGS"
echo "now run ssh -L 9001:localhost:9001 bewest.io"
$SOCAT $SOCAT_ARGS &
ssh -R localhost:9001:localhost:9001 insulaudit
#####
# EOF