1846602 Members
1620 Online
110256 Solutions
New Discussion

Re: tee command

 
SOLVED
Go to solution
SSP_1
Regular Advisor

tee command

Hi,

If I try "tar -cvf /dev/rmt/1mn home opt | tee /backuplogs/bkp1.log" , system is not creating the log file. It is only displaying the o/p on screen.

What may be the possible reasons?
Obstacles exist to challenge you to keep going. Not to quit.
9 REPLIES 9
Robin Wakefield
Honored Contributor
Solution

Re: tee command

Hi,

The output of tar goes to stderr, so you need:

tar -cvf /dev/rmt/1mn home opt 2>&1 | tee /backuplogs/bkp1.log

Rgds, Robin
Simon Abbott
Frequent Advisor

Re: tee command

Hello,

It would appear that tar outputs it verbose text to standard error. Try the same command with
tar cvf tarfile file 2> logfile
Obviously this doen't help you with tee. A look at the man page for tee doesn't give any indication that you can use it with standard error, only standard out.

Regards,

Simon.
I'm still working on that one

Re: tee command

Thats cos the output from tar is going to stderr, not stdout - try this:

tar -cvf /dev/rmt/1mn home opt 2>&1 | tee /backuplogs/bkp1.log

HTH

Duncan

I am an HPE Employee
Accept or Kudo
SSP_1
Regular Advisor

Re: tee command

what does 2>&1 mean?
2=stderr & 1=stdoutput right? then what does "2>&1" will do?
Obstacles exist to challenge you to keep going. Not to quit.
Wim Rombauts
Honored Contributor

Re: tee command

Because the output from tar is sent to standard error and tee reeds from standard output.

You need to redirect the tar ouput : tar cvf /dev/rmt/1mn home opt 2>&1 | tee ...
Wim Rombauts
Honored Contributor

Re: tee command

"2>&1" tells the shell to redirect all output that normally would be sent to file descriptor 2 (standard error) to file descriptor 1 (standard output).
Normal output and errors are sent to two different file descriptors so that you can distinguish between them in a script. Normally filedescriptors 1 and 2 are both set to your display.
Deepak Extross
Honored Contributor

Re: tee command

2>&1 means "send stderr (2) to wherever stdout (1) is being output"
Robin Wakefield
Honored Contributor

Re: tee command

Hi,

2>&1 simply means file descriptor 2 (stderr) is a duplicate of file descriptor 1 (stdout), in other words stderr is sent out as if it were stdout.

Rgds, Robin
SSP_1
Regular Advisor

Re: tee command

thanks a lot all.
I am able to come out of it.

Obstacles exist to challenge you to keep going. Not to quit.