If your shell is Bash (or similar), this set of redirections will do the job:
What does it mean?
The redirection operator n>&m makes file descriptor n to be a copy of file descriptor m. So, whe are:
- Opening a new file descriptor, 3, that is a copy of file descriptor 1, the standard output;
- Making file descriptor 1 a copy of file descriptor 2, the standard error output;
- Making file descriptor 2 to be a copy of file descriptor 3 (the "backup" of the standard output)
in a short: we swapped the standard output and the standard error output.
Doubt regarding using "exec" command to redirect the STDERR to a file. e.g I did it this way.
mystage.sh
#!/bin/sh exec 2>stage.err
....
....
cat stage.err
mv: cannot move `/root/stage' to a subdirectory of itself, `/root/stage_old/stage'
ls: *.zDB: No such file or... (0 Replies)
I am trying to use one global declaration --> "exec 2>$ERR" to capture all stderr outputs that may occur anywhere in my script.
Then close it at the end of the script using --> "exec 2<&-"
I am using KSH on Solaris 8.
KSH Version M-11/16/88i
If I comment two "exec .." statements in the... (11 Replies)
I want to use the "--totals" option in GNU tar for some reporting, however I have discovered that it writes the output to stderr not stdout and I would like to know why. This is running from BASH.
mkdir /tmp/test
touch /tmp/test/foo.file
cd /tmp/
tar --totals -clpzf test.tar.gz test 2>... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
First post here, so hopefully all guidelines are followed, and thanks in advance for any replies.
I'm working on a shell script(BASH) that processes a csv file and performs various tasks with the data. All is well, except I want to use 'tee' to send output from 'wc' to a file as well as pipe it... (4 Replies)
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)
Greetings, everyone.
1. The problem statement, all variables and given/known data:
I'm running into a problem with my program concerning the actual output it does. When I open the file that gets the output, it contains
a large number of hex(?) variables and not what the user wants. The... (0 Replies)
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)
Hi,
How to append content into a file using tee command
echo " file1 is archived"| tee -a archive.txt
echo " file2 is archived"| tee -a archive.txt
echo " file3 is archived"| tee -a archive.txt
how to append content as new rows in the archive.txt
Thanks,
Srinadh. (4 Replies)
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
LEARN ABOUT DEBIAN
multitee
multitee(1) General Commands Manual multitee(1)NAME
multitee - send multiple inputs to multiple outputs
SYNTAX
multitee [ -bsize ] [ -vQq ] [ fd-fd,fd,fd... ] ...
DESCRIPTION
multitee sends multiple inputs to multiple outputs. Given an argument of the form fdin-fdout,fdout,fdout... it will send all input on
file descriptor fdin to each descriptor fdout. It will exit when all fdin are closed. Several arguments may specify outputs from the same
fdin.
-fdout and ,fdout are equivalent. If there is an error of any sort (including SIGPIPE) in writing to fdout, multitee prints a warning on
stderr and forgets fdout entirely. (This doesn't affect reads on fdin.) If -fdout is replaced by :fdout then multitee will exit upon any
SIGPIPEs from that descriptor.
Furthermore, efd means that as soon as fdin reaches end of file, fd is considered to reach EOF as well. multitee will warn about any input
errors and then treat them like EOF.
Unlike tee, multitee tries its best to continue processing all descriptors even while some of them are blocked. However, it will get stuck
reading if someone else is reading the descriptor and grabs the input first; it will get stuck writing if an input packet does not fit in
an output pipe. (If the output descriptor has NDELAY set, and multitee receives EWOULDBLOCK, it writes one byte at a time to avoid pipe
synchronization problems.) While it is tempting to set the descriptors to non-blocking mode, this is dangerous: other processes using the
same open file may not be able to deal with NDELAY. It is incredible that none of the major UNIX vendors or standards committees has come
up with true per-process non-blocking I/O. (Under BSD 4.3 and its variants, multitee could send timer signals to itself rapidly to inter-
rupt any blocking I/O. However, this cannot work under BSD 4.2, and is generally more trouble than it's worth.) A program can set NDELAY
before invoking multitee if it knows that no other processes will use the same open file.
multitee will also temporarily stop reading an input descriptor if more than 8192 bytes are pending on one of its output descriptors. This
does not affect independent fdin-fdout pairs.
multitee has several flags:
-bsize Change input buffer size from 8192 to size. Unlike the previous version of multitee, this version does not require output buf-
fers, and does not copy bytes anywhere between read() and write().
-v Verbose.
-q Quiet. multitee will not use stderr in any way (except, of course, if descriptor 2 is specified in an argument).
-Q Normal level of verbosity.
EXIT VALUE
0 normally. 1 for usage messages. 3 if multitee runs out of memory. 4 in various impossible situations.
DIAGNOSTICS
fatal: out of memory
multitee has run out of memory.
warning: cannot read descriptor
Self-explanatory.
warning: cannot write descriptor
Self-explanatory.
EXAMPLES
multitee 0-1,4,5 4>foo 5>bar
Same as tee foo bar except for better blocking behavior.
multitee 0:1 3:1 4:1,2 6:7
Merge several sources into the output, meanwhile copying 6 to 7 and recording 4's input in 2.
tcpclient servermachine smtp multitee 0:7 6:1e0
Same as mconnect on Suns. The e0 tells multitee to quit as soon as the network connection closes.
RESTRICTIONS
multitee expects all descriptors involved to be open. Currently a closed descriptor acts like an open descriptor which can never be writ-
ten to.
BUGS
None known.
VERSION
multitee version 3.0, 7/22/91.
AUTHOR
Placed into the public domain by Daniel J. Bernstein.
SEE ALSO tee(1)multitee(1)