Don't know if I understand your question correct, but this works I think:
If no error, result is only in file "errs", if error result is both on screen and in file "errs".
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT DEBIAN
data::stag::basegenerator
Data::Stag::BaseGenerator(3pm) User Contributed Perl Documentation Data::Stag::BaseGenerator(3pm)NAME
Data::Stag::BaseGenerator - base class for parsers and other event generators
SYNOPSIS
# writing the parser
package MyParser;
use base qw(Data::Stag::BaseGenerator);
sub parse_fh {
my ($self, $fh) = shift;
my $lnum = 0;
$self->start_event('data');
while (<$fh>) {
++$lnum;
$self->line_no($lnum);
# do stuff
$self->start_event('foo');
# ...
$self->event(blah=>5);
#
if (/incorrect_line/) {
$self->parse_err('line not in correct format');
}
# ...
$self->end_event('foo');
}
$self->pop_stack_to_depth(0);
}
1;
# using the parser
my $p = MyParser->new;
my $h = MyHandler->new; # see Data::Stag::BaseHandler
my $eh = Data::Stag->makehandler;
$p->handler($h);
$p->errhandler($eh);
$p->parse($file);
# result tree
print $h->stag->xml;
# write parse errs on standard err
printf *STDERR $p->errhandler->stag->xml;
# using the parser from the command line
unix> stag-parse.pl -p MyParser -w xml -e err.xml > out.xml
# using the parser from the command line via intermediate handler
unix> stag-handle.pl -p MyParser -m MyHandler -w xml -e err.xml > out.xml
DESCRIPTION
This is the base class for all parsers and event generators
parsers/generators take some input (usually a filehandle, but a generator could be a socket listener, for example) and fire stag events
stag events are
start_event NODENAME
evbody DATA
end_event NODENAME {optional}
event NODENAME DATA
These events can be nested/hierarchical
If uncaught, these events are stacked into a stag tree, which can be written as xml or one of the other stag formats
specialised handlers can be written to catch the events your parser throws
For example, you may wish to write a pod parser that generates nested events like this:
<pod>
<section>
<type>head1</type>
<name>NAME</name>
<text>Data::Stag - Structured Tags datastructures</text>
</section>
...
</pod>
(see the source for Data::Stag::PodParser for details)
You can write handlers that take the pod-xml and generate something - for example HTML
parsers may encounter unexpected things along the way - they may throw an exception, and fall over - or they may choose to fire an error
event. by default, error event streams are diverted to STDERR. You can create your own error handlers
PUBLIC METHODS
new
Title: new
Args:
Return: L<Data::Stag::BaseGenerator>
Example:
CONSTRUCTOR
handler
Title: handler
Function: GET/SET ACCESSOR METHOD
Args: handler L<Data::Stag::BaseHandler> optional
Return: L<Data::Stag::BaseHandler>
Example: $p->handler(MyHandler->new);
each parser has a handler - all events generated are passed onto the handler; the default handler simply sits there collecting events
errhandler
Title: errhandler
Function: GET/SET ACCESSOR METHOD
Args: handler L<Data::Stag::BaseHandler> optional
Return: L<Data::Stag::BaseHandler>
Example: $p->errhandler(Data::Stag->makehandler);
each parser has an error handler - if the parser encounters things it does not expect, it can pass errors to the errorhandler
if no errorhandler is set, an XML event handler that writes to STDERR is used
cache_errors
Title: cache_errors
Args:
Return:
Example: $p->cache_errors
If this is called, all errors will be cached rather than written to STDERR
The error list can be accessed like this
$p->parse($fn);
@errs = $p->errhandler->stag->get_error;
parse
Example - $parser->parse($file1, $file2);
Returns -
Args - filenames str-LIST
parses a file
parse
Example - $parser->parse_fh($fh)
Returns -
Args - fh FILEHANDLE
parses an open filehandle
PROTECTED METHODS
These methods are only of interest if you are making your own parser/generator class
start_event NODENAME
evbody DATA
end_event NODENAME {optional}
event NODENAME DATA
SEE ALSO
Data::Stag Data::Stag::BaseHandler
perl v5.10.0 2008-06-03 Data::Stag::BaseGenerator(3pm)