Search code examples
linuxsocat

How return output in local machine from socat command linux


I have an up and running service ( is an emulated machine or something similar ) on my local Ubuntu machine and i'm able to access it through a serial port and following socat command:

> sudo socat file:`tty`,raw,escape=0x1d,echo=0 unix-connect:/tmp/sample-serial
root@sample:~#

I exit from the service and with the following socat command i can execute the bash file ( is in local machine ) to this service.

> sudo socat file:my_bash_script.sh unix-connect:/tmp/sample-serial

If i enter again with the first socat command in the service i can see my_bash_script.sh output going on in the service terminal

The question is: how i can see the output of this my_bash_script.sh from local machine? Consider that in the service, socat command not exist then i can't open a TCP connections or similar.

Kind Regards


Solution

  • in the second command, the file: address appends the command output to the script. Try something like

    sudo socat file:my_bash_script.sh!!- unix-connect:/tmp/sample-serial

    to get command output on your terminal.

    Please note that '!' may substitute part of the command line with some terminal history, type

    set +H

    to turn this behaviour off.