Re: Standard output piping problem
From: Netocrat (netocrat_at_dodo.com.au)
Date: 05/29/05
- Next message: Netocrat: "Re: Standard output piping problem"
- Previous message: Bill Marcum: "Re: Standard output piping problem"
- In reply to: Bill Marcum: "Re: Standard output piping problem"
- Next in thread: Netocrat: "Re: Standard output piping problem"
- Reply: Netocrat: "Re: Standard output piping problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 28 May 2005 23:36:51 GMT
Bill Marcum wrote:
> On Sat, 28 May 2005 20:20:57 GMT, Netocrat
> <netocrat@dodo.com.au> wrote:
>>
>> $ /usr/sbin/pppstats -w 1 | sed {s/foo//}
>> IN PACK VJCOMP VJUNC VJERR | OUT PACK VJCOMP VJUNC
>> NON-VJ
>> 247460383 589368 0 0 0 | 169639067 621658 0 0
>> 621658
>>
>> BUT:
>>
>> $ /usr/sbin/pppstats -w 1 | sed {s/foo//} | grep "" -
>> [no results]
>> $ /usr/sbin/pppstats -w 1 | grep "" - | sed {s/foo//}
>> [no results]
>>
>> Why won't the multiple pipes present output?
>>
>>
> Because you are not waiting long enough for the buffers to fill?
True... Barry in his reply suggested that it's a buffering issue and to test
this I let the script run for a few minutes. Eventually I got output in a
rush.
> Besides, you don't need grep when sed is in the pipe (but this is
> obviously just an example, maybe your real script uses something other
> than grep?)
Truth be told I was going to use grep as it was simpler than working out how
to remove empty lines with sed. As it turns out it probably wasn't due to
these issues...
So the script I wanted to use ultimately is:
#!/bin/sh
/usr/sbin/pppstats -w 1 |
sed "{s/\([[:space:]]*\([0-9]*\).*|[[:space:]]*\([0-9]*\).*\)/\2 \3/}" |
grep -v ^[[:space:]]$ -
This works correctly but the buffering delays the output which I want in
realtime, so either I don't use grep or I find a way to modify buffering.
The first option seems most appropriate and portable.
I need to find out how to achieve the task of removing lines consisting of
simply a space with the sed script rather than the final grep pipe. I'll
work on it, but if anyone can post a quick solution that'd be great.
- Next message: Netocrat: "Re: Standard output piping problem"
- Previous message: Bill Marcum: "Re: Standard output piping problem"
- In reply to: Bill Marcum: "Re: Standard output piping problem"
- Next in thread: Netocrat: "Re: Standard output piping problem"
- Reply: Netocrat: "Re: Standard output piping problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|