make socat constantly listen for the magic packet

All we need is an easy explanation of the problem, so here it is.

I have a RPi 1b+ v1.2 with Raspbery Pi OS June 2021.

I’m using socat to trigger a bash script that wakes another pc in the network up. I use this command:

sudo socat UDP-LISTEN:10 EXEC:scripts/pi-wol.sh,fork
but in throws an error 2021/09/05 19:26:38 socat[1743] E parseopts(): option "fork" not supported with this address type.

It works fine without fork but only once and I need it to constantly listen. Any ideas how can I do that?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Sounds like you’d rather want:

socat -u udp-recvfrom:10,fork exec:scripts/pi-wol.sh

For upon every received UDP packet, fork a process to handle it and send the contents of the packet on the stdin of a new invocation of that script.

-u for unidirectional unless you want the output of the script to be sent back as UDP packets to the client.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply