tee + more command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tee + more command
# 1  
Old 12-15-2010
tee + more command

script1:
Code:
 
#!/bin/ksh
more test.txt

script2: calling the script1
Code:
 
#!/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 works fine but we need to capture the standard output and error into tee.log.

Is there any workaround or solution for this requirement, to get the output pagewise on screen as well capute the output into tee.log

your replies are highly appreciated.

Thanks
P-
# 2  
Old 12-16-2010
Quote:
Originally Posted by prasad111
script1:
Code:
 
#!/bin/ksh
more test.txt

script2: calling the script1
Code:
 
#!/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 works fine but we need to capture the standard output and error into tee.log.

Is there any workaround or solution for this requirement, to get the output pagewise on screen as well capute the output into tee.log

When the output of more is not a terminal, it doesn't pause.

If you want the ouput of tee to be paged, you have to pipe that into more:
Code:
... | tee tee.log | more

# 3  
Old 12-16-2010
Thanks for the reply,
I won't be able to use more in the script2 as you suggested, because the script1 is menu driven, [It's not shown to keep it simple for the problem]
Script1:
Code:
 
        echo "\t  1 = Users list"
        echo "\t  "
        echo "\t  2 = Session list"
        echo "\t  "
        echo "\t  3 = Advanced Menu"
        echo "\t          "
        echo "\t  e = Exit"
        echo "\t  "
        echo "\t  Please enter your choice==> \c"
        read answer
.............................<more code>............
echo "\n\tDo you want to view the users list (y,n)?\c"
  read ANS
  if [  "${ANS}" = "Y" -o "${ANS}" = "y" ]; then
     clear
     echo "\tNOTE:Press q to exit from viewing\n"
     cat ${USER_LIST_FILE} | more
  fi

In one of the step, it asks for user to view the file that's where more command is used so that the user can view the file and enter the requirement parameters.
# 4  
Old 12-16-2010
Quote:
Originally Posted by prasad111
Script1:
Code:
 
cat ${USER_LIST_FILE} | more


Why are you using cat as well as more?
Why have you not quoted the variable expansion?
Why have you used braces?

That line should be:
Code:
more "$USER_LIST_FILE"

Quote:
In one of the step, it asks for user to view the file that's where more command is used so that the user can view the file and enter the requirement parameters.

Whatever the reason for using it, its effect is lost once you pipe its output to another command. It's the same as using cat.
# 5  
Old 12-16-2010
Thanks for the suggestion, I will correct the code to just use
Code:
 
more "$USER_LIST_FILE"

So to the real problem printing the output on the screen and capturing the tee.log, from your reply, it looks like we don't have a solution/workaround for this.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required with Stderr and tee command

Hello All, I have a requirement to redirect stdout and stderr to 'log' file and stderr alone to 'err' file. Can someone please help me with this? Thanks in advance (2 Replies)
Discussion started by: vikas_trl
2 Replies

2. Shell Programming and Scripting

Question about tee command

I have the following script as shown below where I cat a file and then also tee the output to a file as I have to email the execution of the process to users at the end of the script: cat incoming.dat | tee -a execution.log if then echo "Issue with incoming.dat file, file not... (5 Replies)
Discussion started by: calredd
5 Replies

3. UNIX for Dummies Questions & Answers

Problems with tee command.

for i in /tmp/*filex*; do echo $i |sed 's/\/tmp/infofiles\/infosize\/db\/files\///g';done 2>&1 |tee>output | The script works fine, but I cannot get the output to go to the screen and output at same time. I've tried tee -a tee and a number of commands but the only way I can get it working is... (3 Replies)
Discussion started by: newbie2010
3 Replies

4. 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

5. 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

6. UNIX for Dummies Questions & Answers

tee command within variable

Hello If anybody knows something about the following please help me. I am using HP unix. In a script called test.txt i have the following command echo ok | tee test1.txt It works fine.It prints ok on the screen and creates the file test1.txt and puts in the file the "ok". In the same... (2 Replies)
Discussion started by: kostasch
2 Replies

7. HP-UX

HP Unix Tee command.

work.txt M|324324|32424|3431 N|324324|32426|3432 N|324324|32424|3434 M|324324|32424|3435 AIX command: cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt ) which does not work on HP? Please adivse us. Error: cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )... (7 Replies)
Discussion started by: rsampathy
7 Replies

8. Shell Programming and Scripting

Is there a way to tee stderr from a command that's redirecting error to a file?

I'm not a complete novice at unix but I'm not all that advanced either. I'm hoping that someone with a little more knowledge than myself has the answer I'm looking for. I'm writing a wrapper script that will be passed user commands from the cron... Ex: ./mywrapper.sh "/usr/bin/ps -ef |... (1 Reply)
Discussion started by: sumgi
1 Replies

9. UNIX and Linux Applications

Tee with pipe command.

cat work.txt M|324324|32424|3431 M|324324|32424|3431 N|324324|32426|3432 N|324324|32424|3434 M|324324|32424|3435 cat work.txt | tee $( grep '^M' > m.txt ) | $( grep '^N' > n.txt ) cehpny00:/home01/sr38632 $ cat m.txt M|324324|32424|3431 M|324324|32424|3431 M|324324|32424|3435 ... (2 Replies)
Discussion started by: rsampathy
2 Replies

10. Shell Programming and Scripting

command does not return exit status due to tee

Hi, I am using /bin/sh. I want to display the stdout and stderr on the terminal as well as save it in a file, so I'm using this command. gmake all 2>&1 | tee log But even if gmake fails, it's always giving 0 as exit status, i suppose because of tee. # false 2>&1 | tee Log # echo $? 0... (2 Replies)
Discussion started by: anand_bh
2 Replies
Login or Register to Ask a Question