How to shows incessantly output in bash?
Hello!
I have a code in my bash script Code:
OUTPUT=""`yum update` Code:
yum update 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? |
No experience with yum, but do you mean something like this?
Code:
yum update | tee mylogfile |
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 ??? |
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. |
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). |
...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.
|
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...
|
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.
|
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. |
If the OP really finds that "very interesting" then he could have recorded stdout and stderr with something like
Code:
/usr/bin/yum -e10 -y update >> /path/to/log/file 2>&1 |
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. |
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 10:48 AM. |