I have come to a solution but I doubt I will use it since it involves editing users commands dynamically.
My solution comes in two parts:
1. Use a recursive function to track down any error redirection in the issued command:
Return nothing if redirection is not taking place
If redirection is to another channel (Ex: Stdout is channel 1) call the function again on the new channel, if the function returns nothing pass the channel otherwise pass the returned value
Return the file being redirected to if there is one
Return null if the user is redirecting to /dev/null or has turned off that channel(Ex. #>&-)
2. Use named pipes created from the mkfifo command to redirect errors from the users command to both the user file and a temp file to use by the wrapper.
Then when I think about redirection happening before a pipe
Ex:
Now I would need to run the command through a loop and do this process for each piped command, creating a named pipe for each redirection.
If someone sees an easier way great but this is the only way I see to do it. It's my opinion that telling users the errors will be located in a master log file will be easier.
If I forget to set up stderr redirection on execution of a script, is there a way to set that redirection post-exec? In other words, if I have a script running and no errors are being logged... and then I remember that I forgot the 2>&1 on the script... can I turn it on after the fact?
...and... (1 Reply)
Friends
I have to redirect STDERR messages both to screen and also capture the same in a file.
2 > &1 | tee file works but it also displays the non error messages to file, while i only need error messages.
Can anyone help?? (10 Replies)
% ls -ld /usr /foo
ls: /foo: No such file or directory
drwxr-xr-x 14 root wheel 512 May 18 02:49 /usr
% ls -ld /usr /foo 1>/dev/null/
/dev/null/: Not a directory.
% ls -ld /usr /foo 2>/dev/null/
/dev/null/: Not a directory.
^^Why why why doesn't this work for me. Furthermore, where is... (7 Replies)
I have been doing this:
make xyz &> xyz.log &; tail -f xyz.log
The problem with this is that you never can ge sure when "make xyz" is done.
How can I pipe both stderr and stdout into tee so both stderr and stdout are copied both to the display and to the log file?
Thanks,
Siegfried (3 Replies)
I am trying to redirect the output from stderr to a log file from within a bash script. the script is to long to add 2> $logfile to the end of each command. I have been trying to do it with the command exec 2> $logfile This mostly works. Unfortunately, when a read command requires that anything be... (5 Replies)
Hi All,
Solarix/Bash v3x
Im trying to output any standard errors created by the script to a file using the below command:
. runDTE.sh 2> "$DTE_ERROR_FILE"
however the errors do get written to the dir/file stored in $DTE_ERROR_FILE but the error does not appear on the terminal screen in... (4 Replies)
Hi All,
I need to redirect screen o/p of shell script to file , but I don't want to use "tee" :Dcommand
./test.sh 2>&1 | tee /var/tmp/testing`date +'%d%h%Y%T'`.log
but I want to write some code inside the shell script itself so wen I execute
./test.sh
it will display o/p in screen... (3 Replies)
I have to redirect STDERR messages both to screen and also capture the same in a file but STDOUT only to the same file.
I have searched in this formum for a solution, but something like
srcipt 3>&1 >&2 2>&3 3>&- | tee errs
doesn't work for me...
Has anyone an idea??? (18 Replies)
Hello All,
I have a requirement to redirect stdout and stderr to 'log' file and stderr alone to 'err' file.
Can someone please help me with this?
Thanks in advance (2 Replies)
I know that
mmmmm 2> error.txt
will send the error message to the specified file instead of the screen. However, I have seen
>&2
in some scripts, and I can't get it to do anything. A source said it sends stdout and stderr to a file. What file?
Ubuntu 18.04.2; Xfce 4.12.3;... (11 Replies)
Discussion started by: Xubuntu56
11 Replies
LEARN ABOUT MOJAVE
null
null(n) null(n)
__________________________________________________________________________________________________________________________________________________NAME
null - Create and manipulate null channels
SYNOPSIS
package require Tcl
package require memchan
null
_________________________________________________________________DESCRIPTION
The command described here is only available in a not-yet released version of the package. Use the CVS to get the sources.
null creates a null channel which absorbs everything written into it. Reading from it is not possible, or rather will always return zero
bytes. These channels are essentially Tcl-specific variants of the null device for unixoid operating systems (/dev/null). Transfer-
ing the generated channel between interpreters is possible but does not make much sense.
OPTIONS
Memory channels created by null provide one additional option to set or query.
-delay ?milliseconds?
A null channel is always writable and readable. This means that all fileevent-handlers will fire continuously. To avoid starvation
of other event sources the events raised by this channel type have a configurable delay. This option is set in milliseconds and
defaults to 5.
A null channel is always writable and never readable. This means that a writable fileevent-handler will fire continuously and a readable
fileevent-handler never at all. The exception to the latter is only the destruction of the channel which will cause the delivery of an eof
event to a readable handler.
SEE ALSO
fifo, fifo2, memchan, random, zero
KEYWORDS
channel, i/o, in-memory channel, null
COPYRIGHT
Copyright (c) 1996-2003 Andreas Kupries <andreas_kupries@users.sourceforge.net>
Memory channels 2.2 null(n)