When redirecting to /dev/udp, how do you force a packet with newlines to be a single packet?

StackOverflow https://stackoverflow.com/questions/19887126

  •  30-07-2022
  •  | 
  •  

Pregunta

The simplest example is the following:

echo -e "\n\n\n" > /dev/udp/192.168.45.45/9875

Looking at this with tcpdump, it's actually sending 4 packets. If I needed to send a single packet consisting of hex (payload) 0a0a0a, is that possible using the /dev/udp device?

¿Fue útil?

Solución

I tried this and it appears to send just a single packet of four (=trailing newline included) characters:

echo -e "\n\n\n" >/tmp/foo
cat /tmp/foo > /dev/udp/10.211.55.9/42000

The problem appears to be in echo instead of /dev/udp.

Hope this helps. Hannu

Otros consejos

You can eliminate the final \n with -n option:

echo -n -e "\n\n\n" > /dev/udp/192.168.45.45/9875
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top