2
1
On my linux box, when using screen
I can open, read and write to a pseudo terminal with screen
.
After closing it (C-a k y) I can't connect to it again, without restarting socat
, which provides the pseudo terminal.
Just after starting socat
things look like this:
/home/kidmose $ fuser /dev/pts/9
/dev/pts/9: 20960
/home/kidmose $ lsof /dev/pts/9
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
socat 20960 kidmose 5u CHR 136,9 0t0 12 /dev/pts/9
and I can write and read as expected:
/home/kidmose $ echo "uname -a" > /dev/pts/9 && cat /dev/pts/9
uname -a
Linux egki-laptop-linuxmint 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Starting screen
also works once (I can write and read the expected output):
/home/kidmose $ screen /dev/pts/9
uname -a # My input
Linux egki-laptop-linuxmint 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux # Response
(C-a k y) # I kill the window and screen terminates ([screen is terminating])
Now I can no longer connect with screen
nor simply write. Screen immediately exits with [screen is terminating]
and I get the following error when trying to write:
/home/kidmose $ echo "uname -a" > /dev/pts/9 && cat /dev/pts/9
bash: /dev/pts/9: Device or resource busy
Some info:
/home/kidmose $ fuser /dev/pts/9
/dev/pts/9: 20960
/home/kidmose $ lsof /dev/pts/9
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
socat 20960 kidmose 5u CHR 136,9te 0t0 12 /dev/pts/9
/home/kidmose $
Any ideas on why it is 'busy' / unavailable?
I've noticed the 'te
' appears in the lsof
output. Any explanation for that?
My final goal is to have like a virtual terminal on a remote device. Due to NAT etc. I need the remote device to call in to the server, where the the virtual terminal will be.
Edit: As lemonsqueeze put it in his comment:
[A: sh -> socat] --> [B: socat -> pty -> screen]
Machine A TCP Machine B
Where exactly does
socat
come into the picture ? – lemonsqueeze – 2014-10-11T07:06:26.717I run socat with a TCP server and the pseudo terminal(pty), so I can run a shell on another machine and redirect IO from the shell, via TCP to the pty. My goal is to achive a remote shell, but due to NAT i need the "SSH Server" to initiate the connection. Does this make sense? – kidmose – 2014-10-11T13:38:52.000
1Almost. So you have two machines A and B. You want a remote shell on A from B but you can't because A is NAT'ed. So you have A connect to B instead with socat and do some plumbing:
[A: sh -> socat] -> [B: socat -> pty -> screen]
. Something like this ? – lemonsqueeze – 2014-10-11T14:11:37.590Yup. Nice way of formatting it :) – kidmose – 2014-10-12T10:08:06.103
Ok, what command do you use for socat on B ? – lemonsqueeze – 2014-10-12T10:50:50.290
Check this as well http://superuser.com/questions/874133/screen-vs-socat/
– 0andriy – 2015-04-01T13:29:59.537