Visit The New, Modern Unix Linux Community


Using tee command with ablity to provide input for prompts

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Using tee command with ablity to provide input for prompts
# 1  
Using tee command with ablity to provide input for prompts

OS version: RHEL 7.4
Shell : bash

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 ?

Code:
[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]:

# 2  
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.
This User Gave Thanks to Scott For This Post:
# 3  
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.

Andrew
This User Gave Thanks to apmcd47 For This Post:
# 4  
script's a good option I always forget about!

Alternatively alternatively, don't use tee and just read /var/log/yum.log Smilie
This User Gave Thanks to Scott For This Post:
# 5  
There is also an option running in screen session logging the output.
Code:
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 Smilie
The process will continue to run and can be attached again.

It is a great tool and comes on most operating systems.

Hope that helps
Regards
Peasant.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #25
Difficulty: Easy
Google was the first search engine developed for indexing the Internet.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Provide 2 inputs when prompts

Hi All, I am a novice to UNIX, i need to know is there a way to provide 2 inputs when the shell prompts and i need to assign those 2 values to 2 separate variables. I dont want to give those values as a arguments (while running the script). Thanks in advance!! (1 Reply)
Discussion started by: prasanna2166
1 Replies

2. Shell Programming and Scripting

Help with tee command

In the current directory , I have seven files . But when I use the following command , it lists eight files ( 7 files + file_list.xtx) ls -1 | tee file_list.xtx | while read line; do echo $line ; done Does the tee command create the file_list.xtx file first and then executes the ls -1... (1 Reply)
Discussion started by: kumarjt
1 Replies

3. Shell Programming and Scripting

how to run a command line with another user without prompts for password

Hi, I'm writing a script, in the script I need to use tcpdump to capture some packets however it needs root priviledge my computer is configured by school and I have no real root priviledge so I can't use sudo on my computer,like Code: sudo tcpdump ...... I have to use a limited... (1 Reply)
Discussion started by: esolve
1 Replies

4. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

5. Shell Programming and Scripting

Provide input in sqlplus script

Hi guys. I m creating scripts which input multiple value , inside sqlplus script when it prompt/accept do anybody know how to provide multiple value inside sqlplus script when it prompt. like, enter value for first: enter value for second: enter value "save file as " : I m try... (11 Replies)
Discussion started by: tapia
11 Replies

6. Shell Programming and Scripting

tee + more command

script1: #!/bin/ksh more test.txt script2: calling the script1 #!/bin/ksh /tmp/script1.sh 2>&1 | tee tee.log where test.txt contains ~1200 lines. When I execute the script2 the more command does not print pagewise it goes to the end of the line, when I remove the tee command it... (4 Replies)
Discussion started by: prasad111
4 Replies

7. Solaris

pkgadd pkgask still prompts for user input

I create a succesful pkgask 'response' file: pkgask -r xyz.pkg I then attempt to use the 'response' file with pkgadd: pkgadd -nr /home/user/response -d /home/user/xyz.pkg the prompts for user input still appear. I have also tried an 'admin' file but that still prompts for user input as... (1 Reply)
Discussion started by: prkfriryce
1 Replies

8. Shell Programming and Scripting

running a command without having to provide the path

ok, i am aware of adding the directory where the files are located into the .profile file but the problem is, its not working for me. can someone please spell out how to properly edit these configuration files so i can run a command anywhere on the system without having to be in the... (2 Replies)
Discussion started by: Terrible
2 Replies

9. Shell Programming and Scripting

log script input and output using tee ?

hi, new to to forum... i've been trying to create a script in tcsh but i'm having a problem with one thing... the script has to keep log of it's input and output so i'm using tee -a log | script | tee -a log this keeps the logs as asked, but it gives me an extra empty prompt (not in the... (0 Replies)
Discussion started by: moseschrist
0 Replies

10. Shell Programming and Scripting

script providing input to application prompts

Hi! I want to write a script that will create an archive (via tar) that will restrict the size of the tar file. The size can be constrained using the keyword 'k' and providing the size restriction. The problem is that the script needs to know (detect) when the tar command prompts the user (which... (2 Replies)
Discussion started by: mitch8
2 Replies

Featured Tech Videos