redirecting screen to file without tee


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting redirecting screen to file without tee
# 1  
Old 04-15-2011
redirecting screen to file without tee

Hi All,

I need to redirect screen o/p of shell script to file , but I don't want to use "tee" Smiliecommand
Code:
./test.sh 2>&1 | tee /var/tmp/testing`date +'%d%h%Y%T'`.log

but I want to write some code inside the shell script itself so wen I execute
Code:
./test.sh

it will display o/p in screen as well as in the back it will create file /var/tmp/testing`date +'%d%h%Y%T'`.log and put tat o/p the Smilie

I m struck Smilie is it possible in shell

regards
TaD

Last edited by Franklin52; 04-15-2011 at 04:40 AM.. Reason: Please use code tags
# 2  
Old 04-15-2011
Why you dont want to use tee command..? However try below, pretty awkward though
Code:
./test.sh  2>&1 |cat > out_`date +'%d%h%Y%T'`.log; cat out_`date +'%d%h%Y%T'`.log
or
./test.sh 2>&1 >  out_`date +'%d%h%Y%T'`.log; cat out_`date +'%d%h%Y%T'`.log

# 3  
Old 04-15-2011
@michaelrozar17
I just want to exec

Code

./test.sh

I want to put some code inside in test.sh so when I execute

code

./test.sh
it shud automatically save screen o/p in /var/tmp/testing`date +'%d%h%Y%T'`.log as well

that I don't have any issue in tee or any other command , sorry I wasn't clear in enough in first post
regrd
TaD
# 4  
Old 04-15-2011
One way would be to create a log file using a variable and re-direct the all the output to the log file. At the end of the script open the file to display the output in the screen.
Code:
$cat test.sh
LOG_FILE="/var/tmp/testing`date +'%d%h%Y%T'`.log"
..
... > $LOG_FILE
.. >> $LOG_FILE
cat $LOG_FILE

$./test.sh


Last edited by michaelrozar17; 04-15-2011 at 06:36 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Tee doesn't write all displayed data into text file

"Debain 9 - LXDE" I execute follow line in the bash terminal: /ts3/server/ts3server_startscript.sh start createinifile=1 | tee -a /ts3/server/key.txt The displayed output looks like follow: My key.txt file looks like follow: How can i save the whole displayed text in my file? Why does... (5 Replies)
Discussion started by: int3g3r
5 Replies

2. Shell Programming and Scripting

Mindboggling difference between using "tee" and "/usr/bin/tee" in bash

I'm on Ubuntu 14.04 and I manually updated my coreutils so that "tee" is now on version 8.27 I was running a script using bash where there is some write to pipe error at some point causing the tee command to exit abruptly while the script continues to run. The newer version of tee seems to prevent... (2 Replies)
Discussion started by: stompadon
2 Replies

3. Shell Programming and Scripting

The pipe not use "tee" to print on the screen for specific function

I have code fragment like { aa bb cc } > $LOG aa bb cc, all call function "ff", I want "ff" to print on the screen,but others do not print on the scree, is there a method? I can't use "tee", becasue tee I meet the write "error" ff() { echo "hello" } (2 Replies)
Discussion started by: yanglei_fage
2 Replies

4. Shell Programming and Scripting

Redirecting STDERR to file and screen, STDOUT only to file

I have to redirect STDERR messages both to screen and also capture the same in a file but STDOUT only to the same file. I have searched in this formum for a solution, but something like srcipt 3>&1 >&2 2>&3 3>&- | tee errs doesn't work for me... Has anyone an idea??? (18 Replies)
Discussion started by: thuranga
18 Replies

5. Shell Programming and Scripting

Automatically send stdout and stderror to a file as well as to the screen, but without using tee

Hi, I've been using the following commands in my automated scripts, to ensure that all text output is sent to a log file instead of to the screen: exec 1>>$SCRIPT_LOG_FILE exec 2>>$SCRIPT_LOG_FILE However, I've now discovered that the system used for automating the script executions... (4 Replies)
Discussion started by: confusedAdmin
4 Replies

6. Shell Programming and Scripting

Screen output is blocked by "| tee" command

BACK STORY: I have a script build.py . (It's for creating the ISO file for a special edition of Swift Linux.) This build.py script executes the mintConstructor.py script that I use to modify the Regular Swift Linux ISO to get the special edition Swift Linux ISO. The lines of the script that... (2 Replies)
Discussion started by: swiftlinux
2 Replies

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

8. Shell Programming and Scripting

STDERR to file & terminal using tee

Hi All, Solarix/Bash v3x Im trying to output any standard errors created by the script to a file using the below command: . runDTE.sh 2> "$DTE_ERROR_FILE" however the errors do get written to the dir/file stored in $DTE_ERROR_FILE but the error does not appear on the terminal screen in... (4 Replies)
Discussion started by: satnamx
4 Replies

9. UNIX for Dummies Questions & Answers

help in redirecting output to multiple logfiles without displaying it on the screen

Hi, 1.some_command > logfile1 2>&1 will redirect everything to the file logfile1 without displaying the output of the command on the screen. 2.some_command | tee logfile1 | tee logfile2will redirect the output to logfile1 and logfile2, as well as display the output of the command on the... (1 Reply)
Discussion started by: akhila
1 Replies

10. UNIX for Dummies Questions & Answers

cat, grep and tee to a local file

Hi, This is what I am trying to do. 1) connect to 3 remote servers from my local machine serverA serverB serverC 2) read error file from each server cat /var/lib/mysql/mydb.err 3) grep for lines displaying "yesterday" date grep "`date +%y%m%d' '-d\"1 day ago\"`" 4) Append those lines to a... (7 Replies)
Discussion started by: shantanuo
7 Replies
Login or Register to Ask a Question