Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect application output to unix socket

Tags:

bash

unix

sockets

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?

like image 541
Semyon Bayandin Avatar asked Jan 30 '26 00:01

Semyon Bayandin


1 Answers

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:

ping 127.0.0.1 | socat - unix-connect:/tmp/unixsockettest.sock
like image 158
larsks Avatar answered Feb 01 '26 16:02

larsks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!