Home:ALL Converter>Redirect application output to unix socket

Redirect application output to unix socket

Ask Time:2022-12-04T01:52:33         Author:Semyon Bayandin

Json Formatter

I have a socket server which creates unix socket and then reads data from this unix socket. Then I have another long-process application and I want to redirect stdout of this process to my unix socket. I tried this command to test

ping 127.0.0.1 > /tmp/unixsockettest.sock

But I get -bash: /tmp/unixsockettest.sock: No such device or address. Is it possible to redirect application output to unix socket?

Author:Semyon Bayandin,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74669219/redirect-application-output-to-unix-socket
larsks :

You can't redirect out to a Unix socket using shell i/o redirection, but you can use a tool like socat (which is probably packaged for your distribution) to accomplish the task:\nping 127.0.0.1 | socat - unix-connect:/tmp/unixsockettest.sock\n",
2022-12-03T18:09:00
yy