1833163 Members
3723 Online
110051 Solutions
New Discussion

Log what a script does

 
SOLVED
Go to solution
Charles Holland
Trusted Contributor

Log what a script does

Trying to write a small script to back up ALL of anything that has to do with DP5.5 before upgrading. I am using tar to back everything up and I'd like for the process to create a log for my review to know that there were no problems.

#!/sbin/sh
# Purpose
# Back up any and everything associated with DataProtector
# in preperation of upgading from 5.5 to 6.1
/sbin/tar -cvf /dev/rmt/0mn \
/sbin/init.d/omni \
/sbin/rc1.d/K162omni \
/sbin/rc2.d/S838omni \
/etc/opt/omni \
/opt/omni \
/opt/omni/newconfig/etc/opt/omni \
/opt/omni/newconfig/var/opt/omni \
/opt/omni/newconfig/opt/omni \
/var/opt/omni \
&1> /tmp/omni_bu_list
/usr/bin/mt -f /dev/rmt/0mn offl

Everything was working and then I inserted the next to last line in order to try and get a log. Messed around with trying to use the function "tee" but that didn't work. Looking for suggestions here

Ususally reward points quickly.
Thanks in advance.
"Not everything that can be counted counts, and not everything that counts can be counted" A. Einstein
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: Log what a script does

Crude, perhaps, but you could just use the script command before invoking your script. The -v option to your tar command should ensure that every backup object is logged on the screen and the script command will capture that output. That would eliminate the need for your next to last line entirely.


Pete

Pete
James R. Ferguson
Acclaimed Contributor
Solution

Re: Log what a script does

Hi Charles:

The verbose output of 'tar' goes to STDERR, so you need :

# tar -cvf /dev/rmt/0mn f1 f2 2>&1 |tee -a /tmp/omni_bu_list

Regards!

...JRF...
Charles Holland
Trusted Contributor

Re: Log what a script does

Peete - you are right using the -v command. Problem is I can't read that fast.

James - exactly what I was looking for.

Regards and thanks to both.
"Not everything that can be counted counts, and not everything that counts can be counted" A. Einstein
Pete Randall
Outstanding Contributor

Re: Log what a script does

You don't need to read that fast - the script command puts the output into a file called "typescript" by default, though you can supply a name of your choice. As always, check the "script" man page for details.


Pete

Pete