-   Linux - Newbie (
-   -   How to shows incessantly output in bash? (

sluge 02-22-2013 04:36 AM

How to shows incessantly output in bash?
I have a code in my bash script


OUTPUT=""`yum update`
echo $OUTPUT
echo $OUTPUT >> mylogfile


yum update
is a very long command and without my script it always output something to console, but in my script it starts, for the long time nothing outputs and after a while outputs a lof of data.
Is any way in my script to output data as soon as it is available, but not all data in the same time after long waiting?

millgates 02-22-2013 04:49 AM

No experience with yum, but do you mean something like this?


yum update | tee mylogfile

RaviTezu 02-22-2013 04:55 AM

Hi sluge,

Correct me if I'm understating you wrong.

Are you trying to redirect the output of "yum update" command to a file named mylogfile ???

Habitual 02-22-2013 07:16 AM

yum is probably waiting for a Y/N response.

'yum update -y' will answer in the affirmative inside the script. This may lead to undesirable updates being installed.

jpollard 02-22-2013 10:19 AM

The problem you see is buffering - you can't get any output until all of it is provided...

I use the "script" utility to record activity (both output and input).

unSpawn 02-22-2013 10:45 AM

...besides all of that when the OP runs 'yum -y update' Yum is configured log to /var/log/yum.log by default so echoing $OUTPUT to some custom file makes no sense at all.

jpollard 02-22-2013 02:14 PM

That log is good... but it only shows what yum did, not what it didn't, or the error messages that occurred along the way. Things like mirror fails, timeouts, conflicts...

unSpawn 02-23-2013 07:44 AM

The point of my post is one should know the system before deciding to re-invent the wheel. Conflicts will obviously always remain an issue that requires human intervention, mirror fails aren't fatal unless none of the mirrors work, timeouts aren't interesting unless the updates won't be fetched from that or another mirror. If verbose or error reporting is required the OP should look at yum-updatesd first.

jpollard 02-23-2013 08:19 AM

What is uninteresting to you might be very interesting to someone else.

ESPECIALLY when they ask for the error message that was generated...

Hence, the use of "script" to record everything.

unSpawn 02-23-2013 09:19 AM

If the OP really finds that "very interesting" then he could have recorded stdout and stderr with something like

/usr/bin/yum -e10 -y update >> /path/to/log/file 2>&1
Why would it be advantageous or necessary to use 'script' for just that?..

jpollard 02-23-2013 09:37 AM

Because that doesn't record the input. What answers to prompts were done?

Using redirection works, but assuming all yes responses is not necessarily complete.

The other advantage script has is that it will make a complete log of the session - so anything done to correct/alter the situation during install (such as doing a "yum clean", killing any stuck processes/locks may also be significant.

sluge 02-26-2013 02:00 AM

Hello, thanks for you answers

So, for the first, log in my script is wtiring using special function func_log:

func_log "My log"

So, tee is not actual here.

All times are GMT -5. The time now is 02:42 AM.