Sponsored Content
Top Forums Shell Programming and Scripting Redirecting STDERR to file and screen, STDOUT only to file Post 302697741 by bakunin on Friday 7th of September 2012 09:46:34 AM
Old 09-07-2012
Quote:
Originally Posted by alister
The y-shaped hose and bucket analogy paints a memorable image. Nicely done.
Thank you for this, as well as the additional info. I was not aware that <stderr> is unbuffered while <stdout> is not, so i have learned more here than i have explained. Nice gain. ;-))


It is probably a good idea to do like i have always done (out of luck - you have given me a reason after all) in my scripts: prepend standard and error output with respective prefixes:

Code:
#! /bin/ksh
...
print -u1 "MSG: $(timestamp) , starting the action"
action
if [ $? -gt 0 ] ; then
     print -u2 "ERR: $(timestamp) , action did not work"
else
     print -u1 "MSG: $(timestamp) , action worked out well"
fi
...

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirecting STDOUT & STDERR

In bash, I need to send the STDOUT and STDERR from a command to one file, and then just STDERR to another file. Doing one or the other using redirects is easy, but trying to do both at once is a bit tricky. Anyone have any ideas? (9 Replies)
Discussion started by: jshinaman
9 Replies

2. Shell Programming and Scripting

Redirecting STDERR message to STDOUT & file at same time

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)
Discussion started by: vikashtulsiyan
10 Replies

3. Shell Programming and Scripting

How to redirect stderr and stdout to a file

Hi friends I am facing one problem while redirecting the out of the stderr and stdout to a file let example my problem with a simple example I have a file (say test.sh)in which i run 2 command in the background ps -ef & ls & and now i am run this file and redirect the output to a file... (8 Replies)
Discussion started by: sushantnirwan
8 Replies

4. Shell Programming and Scripting

sending stdout and stderr to a file

working on a c sell script I think I understand the concept of it, which is: filename >> file.txt (to appaend) or filename | tee -a file.txt (to append) The problem is that my shell script is used with several parameters, and these commands don't seem to work with just filename. They... (2 Replies)
Discussion started by: mistermojo
2 Replies

5. Shell Programming and Scripting

Redirect stdout/stderr to a file globally

Hi I am not if this is possible: is it possible in bach (or another shell) to redirect GLOBALLY the stdout/stderr channels to a file. So, if I have a script script.sh cmd1 cmd2 cmd3 I want all stdout/stderr goes to a file. I know I can do: ./script.sh 1>file 2>&1 OR ... (2 Replies)
Discussion started by: islegmar
2 Replies

6. Shell Programming and Scripting

Preserve output order when redirecting stdout and stderr

Hi, I already searched through the forum and tried to find a answer for my problem but I didn't found a full working solution, thats way I start this new thread and hope, some can help out. I wonder that I'm not able to find a working solution for the following scenario: Working in bash I... (8 Replies)
Discussion started by: Boemm
8 Replies

7. Programming

stderr stdout to a log file

I originally wrote my script using the korn shell and had to port it to bash on a another server. My script is working find for backing up but noticed that now after the move, I am not getting any output to my log files. Using Korn shell, this worked for me for some odd reason. This was sending... (2 Replies)
Discussion started by: metallica1973
2 Replies

8. Shell Programming and Scripting

Redirect STDOUT & STDERR to file and then on screen

Dear all, redirecting STDOUT & STDERR to file is quite simple, I'm currently using: exec 1>>/tmp/tmp.log; exec 2>>/tmp/tmp.logBut during script execution I would like the output come back again to screen, how to do that? Thanks Lucas (4 Replies)
Discussion started by: Lord Spectre
4 Replies

9. Shell Programming and Scripting

Lost redirecting stderr & stdout to 3 files - one each plus combined

Hi folks I need/want to redirect output (stdout, stderr) from an exec call to separate files. One for stderr only and two(!) different (!) ones for the combined output of stderr and stdout. After some research and testing i got this so far : (( exec ${command} ${command_parameters} 3>&1... (6 Replies)
Discussion started by: MDominok
6 Replies

10. Shell Programming and Scripting

Redirect STDOUT & STDERR to file and then on screen

Dear all, redirecting STDOUT & STDERR to file is quite simple, I'm currently using: Code: exec 1>>/tmp/tmp.log; exec 2>>/tmp/tmp.log But during script execution I would like the output come back again to screen, how to do that? Thanks Luc edit by bakunin: please use CODE-tags like the... (6 Replies)
Discussion started by: tmonk1
6 Replies
SCONSIGN(1)						      General Commands Manual						       SCONSIGN(1)

NAME
sconsign - print SCons .sconsign file information SYNOPSIS
sconsign [ options... ] file [ ... ] DESCRIPTION
The sconsign command displays the contents of one or more .sconsign files specified by the user. By default, sconsign dumps the entire contents of the specified file(s). Each entry is printed in the following format: file: signature timestamp length implicit_dependency_1: signature timestamp length implicit_dependency_2: signature timestamp length action_signature [action string] None is printed in place of any missing timestamp, bsig, or csig values for any entry or any of its dependencies. If the entry has no implicit dependencies, or no build action, the lines are simply omitted. By default, sconsign assumes that any file arguments that end with a .dbm suffix contains signature entries for more than one directory (that is, was specified by the SConsignFile () function). Any file argument that does not end in .dbm is assumed to be a traditional .sconsign file containing the signature entries for a single directory. An explicit format may be specified using the -f or --file= options. OPTIONS
Various options control what information is printed and the format: -a, --act, --action Prints the build action information for all entries or the specified entries. -c, --csig Prints the content signature (csig) information for all entries or the specified entries. -d DIRECTORY, --dir=DIRECTORY When the signatures are being read from a .dbm file, or the -f dbm or --format=dbm options are used, prints information about only the signatures for entries in the specified DIRECTORY. -e ENTRY, --entry=ENTRY Prints information about only the specified ENTRY. Multiple -e options may be used, in which case information about each ENTRY is printed in the order in which the options are specified on the command line. -f FORMAT, --format=FORMAT The file(s) to be printed are in the specified FORMAT. Legal values are dbm (the DBM format used when the SConsignFile() function is used) or sconsign (the default format used for an individual .sconsign file in each directory). -h, --help Prints a help message and exits. -i, --implicit Prints the list of cached implicit dependencies for all entries or the the specified entries. --raw Prints a pretty-printed representation of the raw Python dictionary that holds build information about individual entry (both the entry itself or its implicit dependencies). An entry's build action is still printed in its usual format. -r, --readable Prints timestamps in a human-readable string, enclosed in single quotes. -t, --timestamp Prints the timestamp information for all entries or the specified entries. -v, --verbose Prints labels identifying each field being printed. ENVIRONMENT
SCONS_LIB_DIR Specifies the directory that contains the SCons Python module directory (e.g. /home/aroach/scons-src-0.01/src/engine). on the com- mand line. SEE ALSO
scons, scons User Manual, scons Design Document, scons source code. AUTHORS
Steven Knight <knight at baldmt dot com> September 2011 SCONSIGN(1)
All times are GMT -4. The time now is 03:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy