
Hi All, I have this crazy problem and I hope it is possible. Part in my script: svnadmin dump -r1:100 --incremental /srv/my_repo > /srv/my_repo.1-100.dump Output: * Dumped revision 1. * Dumped revision 2. * Dumped revision 3. * Dumped revision 4. * Dumped revision 5. * Dumped revision 6. * Dumped revision 7. * Dumped revision 8. * Dumped revision 9. * Dumped revision 10. Now I want to store the output (standard out/error) to a log file for future reference using this: svnadmin dump -r1:100 --incremental /srv/my_repo > /srv/my_repo.1-100.dump | tee /srv/my_repo.1-100.log But seems not to work. Is this doable with bash or python? TIA, Jay

On Mon, Sep 30, 2013 at 03:46:55PM +0800, Jay Amorin wrote:
Now I want to store the output (standard out/error) to a log file for future reference using this:
svnadmin dump -r1:100 --incremental /srv/my_repo > /srv/my_repo.1-100.dump | tee /srv/my_repo.1-100.log
But seems not to work. Is this doable with bash or python?
I think that's taking standard output, and redirecting it to a file. Then you're piping to tee, which doesn't really do anything since you've already redirected standard output to a file. Maybe try: svnadmin dump -r1:100 --incremental /srv/my_repo 2>&1 | tee /srv/my_repo.1-100.log The 2>&1 bit makes standard error go to wherever standard output is going, and then pipes standard output to tee. -Adam

Replacing with 2>&1 won't help I think as I also need to save the output of svnadmin dump to /srv/my_repo.1-100.dump. Thanks. Jay On Mon, Sep 30, 2013 at 3:54 PM, Adam Bolte <abolte@systemsaviour.com>wrote:
On Mon, Sep 30, 2013 at 03:46:55PM +0800, Jay Amorin wrote:
Now I want to store the output (standard out/error) to a log file for future reference using this:
svnadmin dump -r1:100 --incremental /srv/my_repo > /srv/my_repo.1-100.dump | tee /srv/my_repo.1-100.log
But seems not to work. Is this doable with bash or python?
I think that's taking standard output, and redirecting it to a file. Then you're piping to tee, which doesn't really do anything since you've already redirected standard output to a file.
Maybe try:
svnadmin dump -r1:100 --incremental /srv/my_repo 2>&1 | tee /srv/my_repo.1-100.log
The 2>&1 bit makes standard error go to wherever standard output is going, and then pipes standard output to tee.
-Adam
_______________________________________________ luv-main mailing list luv-main@luv.asn.au http://lists.luv.asn.au/listinfo/luv-main

On Mon, Sep 30, 2013 at 05:34:11PM +0800, Jay Amorin wrote:
Replacing with 2>&1 won't help I think as I also need to save the output of svnadmin dump to /srv/my_repo.1-100.dump.
I see. I didn't notice the ".dump/.log" file extension differences, and I think the "I want to store the output (standard out/error) to a log file" also threw me. So if I understand correctly this time, standard output contains the actual dump to be saved, and the "Dumped revision 0..." text is standard error which is to go to a separate log file as well as displayed? If so, maybe try: svnadmin dump -r1:100 --incremental /srv/my_repo 2>&1 1>/srv/my_repo.1-100.dump | tee /srv/my_repo.1-100.log So now 2>&1 is saying "standard error goes to wherever standard output is currently pointing" but then changing the actual standard output to be directed to your dump file (which shouldn't capture stderr). Then, the only thing left for the pipe operator to capture is the svnadmin stderr. Here's my example test: abolte@ettin:~$ cat test.sh #!/bin/bash echo Standard outout echo Standard error >&2 abolte@ettin:~$ ./test.sh 2>&1 1>output | tee output-error Standard error abolte@ettin:~$ cat output-error Standard error abolte@ettin:~$ cat output Standard outout abolte@ettin:~$ -Adam

Replacing with 2>&1 won't help I think as I also need to save the output of svnadmin dump to /srv/my_repo.1-100.dump.
Why not just something like: svnadmin dump -r1:100 --incremental /srv/my_repo 1>/srv/my_repo.1-100.dump 2>/srv/my_repo.1-100.log ? -- where the "1>" is just for emphasis. -- Smiles, Les.

You need to pull the old switcheroo on the file descriptors.
From the bash cookbook:
$ ./myscript 3>&1 1>stdout.logfile 2>&3- | tee stderr.logfile It in effect swaps stdin and stderr then closes file descriptor 3 once it is finished. (the reason for the - at the end of 2>&3-) (I googled "tee standard error" ;-) Credit where it's due. Regards, Morrie.
-----Original Message----- From: luv-main-bounces@luv.asn.au [mailto:luv-main-bounces@luv.asn.au] On Behalf Of Adam Bolte Sent: Monday, 30 September 2013 5:54 PM To: luv-main@luv.asn.au Subject: Re: Capturing output
On Mon, Sep 30, 2013 at 03:46:55PM +0800, Jay Amorin wrote:
Now I want to store the output (standard out/error) to a log file for future reference using this:
svnadmin dump -r1:100 --incremental /srv/my_repo > /srv/my_repo.1- 100.dump | tee /srv/my_repo.1-100.log
But seems not to work. Is this doable with bash or python?
I think that's taking standard output, and redirecting it to a file. Then you're piping to tee, which doesn't really do anything since you've already redirected standard output to a file.
Maybe try:
svnadmin dump -r1:100 --incremental /srv/my_repo 2>&1 | tee /srv/my_repo.1-100.log
The 2>&1 bit makes standard error go to wherever standard output is going, and then pipes standard output to tee.
-Adam

You need to pull the old switcheroo on the file descriptors.
Yeah, both Morrie's and Adam's solutions are better than mine -- I guess the tee lets you see the log output streaming by (as well as capturing it to a file). But an idiom I often use is: make &>make.log & tail -f --pid $! make.log which could be adapted to this situation by separately redirecting stdout and stderr as in my last mail. That is, instead of using tee to output and capture the log, capture it to a file by simple redirection, and then use tail to follow that file. (In fact, I'd say 'nice make', but that's a different topic.) -- Smiles, Les. P.S. The only gotcha with my solution is that if you ctrl-C in the terminal, it'll just kill off the tail process, and the make process will keep happily on going. You have to kill the make explicitly with a kill command, or I guess foreground it to ctrl-C it.
participants (6)
-
Adam Bolte
-
Allan Duncan
-
Jay Amorin
-
Les Kitchen
-
Morrie Wyatt
-
trentbuck@gmail.com