I would like to assign the output of stdout to a variable and that of stderr to another one, and this without using temporary files/named pipes.
I agree with Corona688, cannot be done without pipes. However, you said 'named pipes' which technically are different beasts so I offer this "mess" for you to consider.
It all can be crammed on one line; I've formatted it to be easier to read. It makes the assumption that the tilde (~) is never found in either the stdout or stderr stream. The records of each output stream are separated with semicolons, so if the output contains them, things will be difficult.
Running the script in my small test environment produced:
I tested this in Kshell; I don't think it will work under bash as bash has issues executing a command and reading the output into variables. It will also be subject to the limits that Kshell might impose on variable value lengths or that awk might impose on string lengths. If you have a command that produces rather long output/error you could have problems.
How can I redirect and append stdout and stderr to a file when using cron? Here is my crontab file:
*/5 * * * * /dir/php /dir/process_fns.php >>& /dir/dump.txt
Cron gives me an 'unexpected character found in line' when trying to add my crontab file.
Regards,
Zach Curtis
POPULUS (8 Replies)
#!/usr/bin/perl
open(STDOUT, ">>$Textfile")
open(STDERR, ">>$Textfile")
print "program running\n";
$final = join("+", $initial,$final) #5
close (STDOUT);
close (STDERR);Hi all, above is my perl code. Notice i have captured the stdout and stderr to the same textfile. my code is expected to... (1 Reply)
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)
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)
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)
I have an executable that, depending on its input, outputs to either one file or several. It usually prints nothing on screen. The usual way to call this program is to specify an input and output filenames, like this:
./executable.exe -i inputfile -o outputfileIt will then try to use the output... (1 Reply)
Hi all. I am trying to use backticks in Perl to put STDERR into a string. The code is...
$readkey_test = `perl -MTerm::ReadKey -e 1`;
print $readkey_test;
if ($readkey_test =~ m/]/)
{
print "ReadKey not installed...\n";
}
else
{
print "ReadKey installed...\n";
}
If it comes up... (3 Replies)
Can somebody explain to me why the diff output is not going to stderr?
Yet when I issue a diff from the command line the return code is -ne 1.
I am guessing diff always writes to stdout???
Is there away I can force the difff to write to stderr USING THE CURRENT
template. If possible, I... (5 Replies)
Hi all,
can someone help me with the next redirection?
i want to redirect the stdout+stderr of a command to the same file (this i can do by prog &> file)
but in addition i want to redirect only the stderr to a different file.
how can i do this please? (in BASH)
thanks. (4 Replies)
Well.. let's say i need to write a pretty simple script.
In my script i have 2 variables which can have value of 0 or 1.
$VERBOSE
$LOG
I need to implement these cases:
($VERBOSE = 0 && $LOG = 0) => ONLY ERROR output (STDERR to console && STDOUT to /dev/null)
($VERBOSE = 1... (5 Replies)
Discussion started by: Marmz
5 Replies
LEARN ABOUT DEBIAN
validlocale
validlocale(8)validlocale(8)NAME
validlocale - Test if a given locale is available
SYNTAX
validlocale <locale>
DESCRIPTION
Test if the locale given as argument is a valid locale. If it isn't, print on stdout the string to add to /etc/locale.gen to make
locale-gen generate the locale (if it exists at all).
FILES
/usr/sbin/validlocale
/usr/share/i18n/SUPPORTED
ENVIRONMENT VARIABLES
DEFAULTCHARSET
Which charset to assume if the given locale is missing from the list of supported locales.
EXAMPLES
If you give a valid locale as parameter, it outputs a string specifying this on stderr:
% validlocale C
locale 'C' valid and available
When given a invalid (not generated or just nonexistent), it outputs a string on stderr telling that this is an invalid locale, and a
string to stdout with the string to add to /etc/locale.gen to have this locale generated:
% validlocale de_AU@euro
locale 'de_AU@euro' not available
de_AU@euro ISO-8859-15
AUTHORS
Petter Reinholdtsen <pere@hungry.com>
SEE ALSO locale-gen(8), localedef(1), locale(1)Petter Reinholdtsen 0.1 validlocale(8)