For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > May 2006 > tee utility









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author tee utility
sri_girish@yahoo.com

2006-05-07, 7:14 pm

I am trying to use the tee for an application. While I use the tee with
the file name, I am getting output on stdout (monitor) and o/p on the
file specified also.
Since the o/p is too bulky (with too many lines) and contains lot of
useless information, I try to grep the information/line required by me
and then piping it to tee. In This case o/p is written to file but
whatever is grepped is available on stdout only when I close/stop the
process/application.

Pl. suggest a way to overcome this.

Thanks
girish

Barry Margolin

2006-05-07, 7:14 pm

In article <1146921753.413835.253860@i39g2000cwa.googlegroups.com>,
"sri_girish@yahoo.com" <sri_girish@yahoo.com> wrote:

> I am trying to use the tee for an application. While I use the tee with
> the file name, I am getting output on stdout (monitor) and o/p on the
> file specified also.
> Since the o/p is too bulky (with too many lines) and contains lot of
> useless information, I try to grep the information/line required by me
> and then piping it to tee. In This case o/p is written to file but
> whatever is grepped is available on stdout only when I close/stop the
> process/application.
>
> Pl. suggest a way to overcome this.


This is due to output buffering, which is the default behavior of stdio
when stdout is connected to something other than a terminal.

Check your grep man page to see if it has an option not to buffer its
output. If it doesn't, install Expect and use its "unbuffer" command.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
sri_girish@yahoo.com

2006-05-10, 7:04 pm

Hi Mr. Barry,

Thank you for the response.

I seacrhed grep, but it doesn't have one to unbuffer. I am using SCO
Unixware 7.1.1. However i have Expect. I tried to unbuffer, but it
doesn't work. ie. when I send <unbuffer mon>, it accepts the command
(i.e. it returns to command/unix prompt). But when I run "#mon" it
still waits for few minutes till the buffer is full to throw the o/p to
stdout.
Problem is I use this mon on OMNI platform. my syntax is something like
this.
#mon|grep -i "msg:" | tee test1

BR

Barry Margolin

2006-05-10, 7:04 pm

In article <1147268347.799503.96740@i39g2000cwa.googlegroups.com>,
"sri_girish@yahoo.com" <sri_girish@yahoo.com> wrote:

> Hi Mr. Barry,
>
> Thank you for the response.
>
> I seacrhed grep, but it doesn't have one to unbuffer. I am using SCO
> Unixware 7.1.1. However i have Expect. I tried to unbuffer, but it
> doesn't work. ie. when I send <unbuffer mon>, it accepts the command
> (i.e. it returns to command/unix prompt). But when I run "#mon" it
> still waits for few minutes till the buffer is full to throw the o/p to
> stdout.
> Problem is I use this mon on OMNI platform. my syntax is something like
> this.
> #mon|grep -i "msg:" | tee test1
>
> BR


unbuffer doesn't modify the program, you have to use the command to
unbuffer that particular invocation. I.e.

unbuffer mon | unbuffer grep -i msg: | tee test1

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
sri_girish@yahoo.com

2006-05-11, 7:03 pm

Nope.

I am using mon (command "#mon|grep -i "msg:" | tee test1" ) from MML. I
tried "unbuffer mon | unbuffer grep -i msg: | tee test1" from MML. It
gives me an error
"Invalid format for MML command
ie: NOTIFAGENT1>>PROC,MML_COMMAND;
or NOTIFAGENT1>>MML_COMMAND;"

When I try unbuffer from unix prompt, unbuffer mon is accepted but for
unbuffer grep it doesnot work and gives out an error.
Pl. suggest.

Barry Margolin

2006-05-12, 4:02 am

In article <1147357727.995849.6770@q12g2000cwa.googlegroups.com>,
"sri_girish@yahoo.com" <sri_girish@yahoo.com> wrote:

> Nope.
>
> I am using mon (command "#mon|grep -i "msg:" | tee test1" ) from MML. I
> tried "unbuffer mon | unbuffer grep -i msg: | tee test1" from MML. It
> gives me an error
> "Invalid format for MML command
> ie: NOTIFAGENT1>>PROC,MML_COMMAND;
> or NOTIFAGENT1>>MML_COMMAND;"


I have no idea what MML is, so I don't know how to help with this part.

>
> When I try unbuffer from unix prompt, unbuffer mon is accepted but for
> unbuffer grep it doesnot work and gives out an error.
> Pl. suggest.


Am I supposed to guess what the error was?

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com