[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Built-in printf Sits Awkwardly with UDP.

From: Sven Mascheck
Subject: Re: Built-in printf Sits Awkwardly with UDP.
Date: Mon, 18 Jul 2011 23:46:19 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Mon, Jul 18, 2011 at 10:46:19AM -0400, Steven W. Orr wrote:
> On 7/18/2011 10:14 AM, Ralph Corderoy wrote:

>>      printf 'foo\nbar\n'>/dev/udp/localhost/4242
>> and two packets are sent, one per line.  If the aim is to send a string
>> of data in one packet this causes problems.
>> Using /usr/bin/printf from coreutils gives one write(2), so that's a
>> possible workaround.

> Bash is always running in unbuffered mode, so every time a line is 
> written, it automatically gets flushed. So... The only way to write in 
> fully buffered mode with control over when things get flushed is to do it 
> from a program that is not a bash script.

If it's just about avoiding a different printf command,

    printf 'foo\nbar\n' | cat > /dev/udp/localhost/4242

(useful use of cat?) but likely not what the original poster wanted,
that is, avoiding any external command...

reply via email to

[Prev in Thread] Current Thread [Next in Thread]