[Summary] ufsdump ksh puzzle

From: Chris Hoogendyk <hoogendyk_at_bio.umass.edu>
Date: Tue May 02 2006 - 14:23:18 EDT
Well, I haven't done this yet. Have to wait until Thursday, when the 
remote tape is free to test this particular case.

However, I've gotten a number of responses, and a summary seems to make 
sense (Original Message below).

The response I liked best and am going to try came from Crist Clark:

     "Try running it in a subshell and then redirect the stdout of _that._

          ( /usr/lib/fs/ufs/ufsdump ${LEVEL}cnlTfuN 2h - ${RDEV} 
${WHICHSNAP} |
            su - backup -c "ssh ${TAPESERVER} \"dd obs=64b 
of=/dev/rmt/0n\"" ) 2>&1 |
            tee -a ${LOGFILE}

     Ugly, but it should work."


This makes sense. I actually use a construct like that to build mail 
messages for error conditions. My only question/concern is whether the 
output will go to the logfile after the subshell has completed or while 
it is processing. If it doesn't have enough inherent unix intelligence 
to write it to the logfile on the fly, then I haven't really gained 
anything, since I still won't know what is going on until it is all over.

Other suggestions that I will put on hold until trying the above 
included (1) using a named pipe and (2) just redirecting to the logfile 
and then cat'ing or tail'ing the logfile to generate output in the cron 
script. I think these will be my fall backs (in the order specified).

The variant of the named pipe that appears to work came from G. Weick. I 
tested it using a silly mistake to generate a standard error output:

1     # mknod tmp-pipe p
2     # tee stderr < tmp-pipe &
3     [1]     24468
4     # ls -l blah 2>tmp-pipe
5     # blah: No such file or directory
6
7     [1] +  Done                    tee stderr < tmp-pipe &
8     # more stderr
9     blah: No such file or directory
0     # rm tmp-pipe

line 4 is where the ufsdump would be. I used a simple ls instead on a 
non-existent file.
line 5 is actually asynchronous output from the foreground and 
background process. Normally the prompt would have followed the error. 
But the prompt came back before the piped error message.
line 6 -- I entered a return to get my prompt back
line 7 -- The background process terminated and then the prompt came 
back on line 8.


Thanks to Crist Clark, Brad Morrison, G. Weick, Michael Maciolek, John 
Julian, Ryan Krenzischek, Dave Mitchell, and Pete Geenhuizen.



---------------

Chris Hoogendyk

-
   O__  ---- Systems Administrator
  c/ /'_ --- Biology & Geology Departments
 (*) \(*) -- 140 Morrill Science Center
~~~~~~~~~~ - University of Massachusetts, Amherst 

<hoogendyk@bio.umass.edu>

--------------- 

Erdvs 4





-------- Original Message --------
Subject: 	ufsdump ksh puzzle
Date: 	Mon, 01 May 2006 15:40:33 -0400
From: 	Chris Hoogendyk <hoogendyk@bio.umass.edu>
To: 	Sun Managers List <sunmanagers@sunmanagers.org>



ufsdump puts its messages out to standard error.

I believe this is to avoid conflict with the case where the dump is 
going to standard out and piped somewhere else (to ufsrestore on another 
partition, or to ssh to dd to a tape drive on another server).

So, suppose you have a cron job running ufsdump piped to ssh to a drive 
on another server. The script runs a long time. You want to know what it 
is doing. So, you set up a log file. Various commands in the script use 
tee to the log file. Then you get a log file you can look at, and when 
it's all done you get a mail message with the output of the cron job.

However, the puzzle is that I can't seem to find any way to redirect 
standard error so that it goes to a log file as well as to the output of 
the cron job that appears in the mail message.

Examples:

This works:

      /usr/lib/fs/ufs/ufsdump ${LEVEL}cnlTfuN 2h /dev/rmt/0n ${RDEV} 
${WHICHSNAP} 2>&1 | tee -a ${LOGFILE};

This also works:

    /usr/lib/fs/ufs/ufsdump ${LEVEL}cnlTfuN 2h - ${RDEV} ${WHICHSNAP} | 
su - backup -c "ssh ${TAPESERVER} \"dd obs=64b of=/dev/rmt/0n\"";

But in the second one I can't use 2>&1, because standard out is the 
dump. I can do 2>logfile, but I can't do .... I have no idea what the 
proper syntax or approach would be.



---------------

Chris Hoogendyk

-
   O__  ---- Systems Administrator
  c/ /'_ --- Biology & Geology Departments
 (*) \(*) -- 140 Morrill Science Center
~~~~~~~~~~ - University of Massachusetts, Amherst 

<hoogendyk@bio.umass.edu>

--------------- 

Erdvs 4
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue May 2 14:24:06 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:57 EST