Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vmstat | sed WORKS vmstat | logger WORKS vmstat | sed | logger FAILS

2 views
Skip to first unread message

jabe_one

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
I am using FreeBSD 3.3. The following two pipes work fine:

vmstat -w 5 | logger -p local0.info
vmstat -w 5 | sed -e /procs/d -e /fre/d

But don't work when combined into:

vmstat -w 5 | sed -e /procs/d -e /fre/d | logger -p local0.info

I don't understand why. Any suggestions?

Barry Margolin

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
In article <#elYr3tp$GA.206@cpmsnbbsa03>,

Sed probably uses stdio, which buffers output when writing to a non-tty.

I'm pretty sure I answered an almost identical question a few days ago in
one of the comp.unix.* newsgroups. Was that you?

--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

jabe_one

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
Yes. I posted a message last Saturday or Sunday and received one reply
recommending to omit the vmstat part. Because vmstat is the source of the
data stream, that didn't make sense to me. I was unable to check any
messages after Sunday and did not find the original or any responses today.

If you have a suggestion, I would appreciate the help.

Barry Margolin <bar...@bbnplanet.com> wrote in message
news:fr1K4.7$Mv3.355@burlma1-snr2...

Barry Margolin

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
In article <#S3O0Cwp$GA.351@cpmsnbbsa04>,

jabe_one <jabe...@email.msn.com> wrote:
>Yes. I posted a message last Saturday or Sunday and received one reply
>recommending to omit the vmstat part. Because vmstat is the source of the
>data stream, that didn't make sense to me. I was unable to check any
>messages after Sunday and did not find the original or any responses today.

The message I responded to was from you, but it didn't have logger; it had

vmstat | sed | sed

I told you to use a single sed with multiple -e options, which is what
you've done.

The problem that was affecting the second sed is now affecting logger -- it
doesn't get anything until sed's output buffer fills up. The only way to
fix it is to make sed's output go to a tty. I think Expect includes a
simple utility to do this.

jabe_one

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
Yes, thanks for the help with sed. By the way, I did get an answer to the
current question that seems to be working fine:

vmstat -w 5 | awk '/^\ [0-9]/ {print | "logger -p local0.info" }'

Barry Margolin <bar...@bbnplanet.com> wrote in message

news:aZ1K4.14$Mv3.87@burlma1-snr2...

Rob Kouwenberg

unread,
Apr 15, 2000, 3:00:00 AM4/15/00
to
jabe_one <jabe...@email.msn.com> wrote:

> I am using FreeBSD 3.3. The following two pipes work fine:
>
> vmstat -w 5 | logger -p local0.info
> vmstat -w 5 | sed -e /procs/d -e /fre/d
>
> But don't work when combined into:
>
> vmstat -w 5 | sed -e /procs/d -e /fre/d | logger -p local0.info
>
> I don't understand why. Any suggestions?

vmstat -w 5 | sed -e '/procs/d; /fre/d' | logger -p local0.info
vmstat -w 5 | grep -v 'procs|fre' | logger -p local0.info


Barry Margolin

unread,
Apr 16, 2000, 3:00:00 AM4/16/00
to
In article <1e95jz8.734mzh1whnb4iN%r...@kouwenberg.com.REMOVETHISSPAMTRAILER.COM>,

Rob Kouwenberg <r...@kouwenberg.com.REMOVETHISSPAMTRAILER.COM> wrote:
>vmstat -w 5 | sed -e '/procs/d; /fre/d' | logger -p local0.info

How does that solve the sed buffering problem?

>vmstat -w 5 | grep -v 'procs|fre' | logger -p local0.info

grep also buffers its output, so this is no solution, either. BTW, I think
you meant "egrep".

It seems like you have no idea what the problem is, and you're just making
random modifications to the OP's command line, without even testing them
(if you don't want to log messages, just replace the logger command with
"cat" and you'll see the problem).

0 new messages