I would like to capture command outputs using tee like # yum upgrade | tee yumupgradeLog
But, if I use tee command, I cannot respond to prompts like Is this ok [y/d/N]: during command execution as shown below.
Is there a way I could use tee and still be able to provide input for prompts ?
[root@localhost ~]# yum upgrade
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.8.0-9.el7 will be updated
---> Package NetworkManager.x86_64 1:1.8.0-11.el7_4 will be an update
---> Package NetworkManager-adsl.x86_64 1:1.8.0-9.el7 will be updated
---> Package NetworkManager-adsl.x86_64 1:1.8.0-11.el7_4 will be an update
---> Package NetworkManager-config-server.noarch 1:1.8.0-9.el7 will be updated
---> Package NetworkManager-config-server.noarch 1:1.8.0-11.el7_4 will be an update
.
.
.
.
Install 9 Packages (+1 Dependent package)
Upgrade 126 Packages
Total size: 365 M
Total download size: 272 M
Is this ok [y/d/N]:
If you provide the -y option to yum, you won't be asked about it. In case there are multiple questions (such as when it's also asking you about GPG keys), you may consider piping yum through yes, or creating a response file and piping that through yum.
Alternatively use script . This starts a sub-shell in your current terminal and saves all output to a file. After you have finished exit the sub-shell and the file is closed for review.
There is also an option running in screen session logging the output.
screen -L -Logfile $HOME/mysession.log -S yumscreen
# do your update
exit
Look for the file $HOME/mysession.log or log/path you require.
You will also benefit in screen if your network connection breaks or similar issues .. turn off putty by accident :rolleyes:
The process will continue to run and can be attached again.
It is a great tool and comes on most operating systems.