I have an embedded linux application with a simple interactive command line interface.
I'd like to access the command line from telnet (or network, in general).
However, the process should be started when the board turns on, and in a unique instance. So, the following netcat
command is not an option:
nc -l -p 4000 -e myapp
I can do
nc -l -p 4000 | myapp
to send remote commands to myapp, but this way I can't see myapp
output.
Is there any way to redirect both stdin and stdout to netcat
?
Thanks.
You can use ncat (from nmap package:
apt install nmap
) for that as well as follow:ncat -lnvp 443 -e myapp
don't forget to
fflush(stdout);
after eachprintf("%s",str);
in your appI found that by using bash v. >= 4.0 I can use
coproc
:There is
socat
, which is a more advancednetcat
. You can redirect bothstdin
andstdout
with it. E.g.:In the above
cat
readsstdin
and/etc/redhat-release
and outputs them intostdout
.And then try using that: