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
  •  | 
  •  

質問

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?

役に立ちましたか?

解決

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

他のヒント

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

echo -n -e "\n\n\n" > /dev/udp/192.168.45.45/9875
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top