All of lore.kernel.org
 help / color / mirror / Atom feed
* hcitool lescan scripting question...
@ 2014-11-11 11:11 Urbani, Edmund
  2014-11-13 16:56 ` Szymon Janc
  0 siblings, 1 reply; 2+ messages in thread
From: Urbani, Edmund @ 2014-11-11 11:11 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org


Hello,

now this may seem like a silly question, but I have been trying to do some 
simple shell scripting with hcitool's LE scan and redirected its out and err 
streams. The result is not quite what I am expecting:

hcitool lescan --duplicates > /tmp/lescan.out

This will create the output file immediately, but it remains empty until the 
hcitool process terminates. Only then does the entire output get flushed. Any 
idea why the output does not get written immediately? Ie. why I can't "tail -f 
/tmp/lescan.out"?

My intention was to pipe the output through a shell script to add a timestamp to 
each line, so I get a simple log during testing. I did not want to modify 
hcitool/write my own C program just for this purpose.

Kind regards,
  Edmund

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: hcitool lescan scripting question...
  2014-11-11 11:11 hcitool lescan scripting question Urbani, Edmund
@ 2014-11-13 16:56 ` Szymon Janc
  0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-11-13 16:56 UTC (permalink / raw)
  To: Urbani, Edmund; +Cc: linux-bluetooth@vger.kernel.org

Hi Edmund,

On Tuesday 11 of November 2014 12:11:02 Urbani, Edmund wrote:
> 
> Hello,
> 
> now this may seem like a silly question, but I have been trying to do some 
> simple shell scripting with hcitool's LE scan and redirected its out and err 
> streams. The result is not quite what I am expecting:
> 
> hcitool lescan --duplicates > /tmp/lescan.out
> 
> This will create the output file immediately, but it remains empty until the 
> hcitool process terminates. Only then does the entire output get flushed. Any 
> idea why the output does not get written immediately? Ie. why I can't "tail -f 
> /tmp/lescan.out"?
> 
> My intention was to pipe the output through a shell script to add a timestamp to 
> each line, so I get a simple log during testing. I did not want to modify 
> hcitool/write my own C program just for this purpose.

This is due to stdout buffering. Try with stdbuf:
stdbuf -oL hcitool lescan --duplicates > /tmp/lescan.out

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-13 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-11 11:11 hcitool lescan scripting question Urbani, Edmund
2014-11-13 16:56 ` Szymon Janc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.