10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Below is Script to scan the errorlist file (errorlist file includes a list of errors) with sererv.log file (sererv.log file should contain data of recent 15mins )
but my requirement is I should get the recent logs i.e. cmd to capture only recent 15mins data logged from sererv.log file then scan... (3 Replies)
Discussion started by: manohar2013
3 Replies
2. Shell Programming and Scripting
Hi All,
I am trying to capture the data in linux .While doing load test.
is there's any sample script please help me.
Linux test4 2.6.18-308.8.1.el5 #1 SMP Fri May 4 16:43:02 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
Thanks, (5 Replies)
Discussion started by: sam1226
5 Replies
3. UNIX for Dummies Questions & Answers
Hi,
I was trying a script to cature all data between 12-05-09 06:00:00 to 12-05-09 23:59:59 from a huge file. (i.e. Skip all data between 00:00:00 to 05:59:59)
TOKEN-1 12-05-09 00:00:00 MAIPR no_OMDB_key #000995 >
..
..
..
TOKEN-1 12-05-09 06:00:00 TRUNK 358 #04988 >
..
..
TOKEN-1 12-05-09... (2 Replies)
Discussion started by: vanand420
2 Replies
4. Shell Programming and Scripting
I have 2 zip files which have about 20 million records in each file. file 2 will have additional records than file 1. I want to compare the records in both the files and capture the new records from file 2 into another file file3. Please help me with a command/script which provides me the desired... (8 Replies)
Discussion started by: koneru
8 Replies
5. UNIX for Advanced & Expert Users
Hi,
I have a query as follows :
suppose I am matching a string in a file say "start from here"
and I want to pick up 'n' number of lines () from the matched string. Is there any way to do that ?
1) going forward I want to do this for every match for the above string
2) or limit this to... (2 Replies)
Discussion started by: sumoka
2 Replies
6. IP Networking
I have a number of Windows CE operator terminals. They have facility to print alarms/messages to ...
aser or Inkjet (so they're using PCL).
USB or IP. IP connection takes just the IP address.
Question
How could I create a service or daemon on a server to capture all this data?... (7 Replies)
Discussion started by: transistor
7 Replies
7. Shell Programming and Scripting
I would like to capture output from two commands to a test file on the same line...
I want to get a file with all Applications and the Version of it...here are the two commands I use to get the output.
To get Application list I use
ls -1 /Applications/ |grep .app >>... (3 Replies)
Discussion started by: elbombillo
3 Replies
8. Shell Programming and Scripting
Hello,
If I run a program from within shell, the output is displayed in the command line terminal. Is there a way I can capture that output and choose only the very last string in it to send it to a new file?
Thank you (6 Replies)
Discussion started by: Lorna
6 Replies
9. UNIX for Dummies Questions & Answers
Hi,
i willbe very much grateful to u if u help me out..
if i simply connect pbx machine to printer by serial port RS232 then we find this view:
But i want to capture this data into database automatically when the pbx is running.The table in database will contain similar to this view inthe... (1 Reply)
Discussion started by: boss
1 Replies
10. Shell Programming and Scripting
Is it possible to capture data posted from a Web Form?? I mean when data in the form on a webpage is send via POST method and not GET method. Can it be captured! (1 Reply)
Discussion started by: azmathshaikh
1 Replies
IO::CaptureOutput(3pm) User Contributed Perl Documentation IO::CaptureOutput(3pm)
NAME
IO::CaptureOutput - capture STDOUT and STDERR from Perl code, subprocesses or XS
VERSION
This documentation describes version 1.1102.
SYNOPSIS
use IO::CaptureOutput qw(capture qxx qxy);
# STDOUT and STDERR separately
capture { noisy_sub(@args) } $stdout, $stderr;
# STDOUT and STDERR together
capture { noisy_sub(@args) } $combined, $combined;
# STDOUT and STDERR from external command
($stdout, $stderr, $success) = qxx( @cmd );
# STDOUT and STDERR together from external command
($combined, $success) = qxy( @cmd );
DESCRIPTION
This module provides routines for capturing STDOUT and STDERR from perl subroutines, forked system calls (e.g. "system()", "fork()") and
from XS or C modules.
FUNCTIONS
The following functions will be exported on demand.
capture()
capture &subroutine, $stdout, $stderr;
Captures everything printed to "STDOUT" and "STDERR" for the duration of &subroutine. $stdout and $stderr are optional scalars that will
contain "STDOUT" and "STDERR" respectively.
"capture()" uses a code prototype so the first argument can be specified directly within brackets if desired.
# shorthand with prototype
capture { print __PACKAGE__ } $stdout, $stderr;
Returns the return value(s) of &subroutine. The sub is called in the same context as "capture()" was called e.g.:
@rv = capture { wantarray } ; # returns true
$rv = capture { wantarray } ; # returns defined, but not true
capture { wantarray }; # void, returns undef
"capture()" is able to capture output from subprocesses and C code, which traditional "tie()" methods of output capture are unable to do.
Note: "capture()" will only capture output that has been written or flushed to the filehandle.
If the two scalar references refer to the same scalar, then "STDERR" will be merged to "STDOUT" before capturing and the scalar will hold
the combined output of both.
capture &subroutine, $combined, $combined;
Normally, "capture()" uses anonymous, temporary files for capturing output. If desired, specific file names may be provided instead as
additional options.
capture &subroutine, $stdout, $stderr, $out_file, $err_file;
Files provided will be clobbered, overwriting any previous data, but will persist after the call to "capture()" for inspection or other
manipulation.
By default, when no references are provided to hold STDOUT or STDERR, output is captured and silently discarded.
# Capture STDOUT, discard STDERR
capture &subroutine, $stdout;
# Discard STDOUT, capture STDERR
capture &subroutine, undef, $stderr;
However, even when using "undef", output can be captured to specific files.
# Capture STDOUT to a specific file, discard STDERR
capture &subroutine, $stdout, undef, $outfile;
# Discard STDOUT, capture STDERR to a specific file
capture &subroutine, undef, $stderr, undef, $err_file;
# Discard both, capture merged output to a specific file
capture &subroutine, undef, undef, $mergedfile;
It is a fatal error to merge STDOUT and STDERR and request separate, specific files for capture.
# ERROR:
capture &subroutine, $stdout, $stdout, $out_file, $err_file;
capture &subroutine, undef, undef, $out_file, $err_file;
If either STDOUT or STDERR should be passed through to the terminal instead of captured, provide a reference to undef -- "undef" --
instead of a capture variable.
# Capture STDOUT, display STDERR
capture &subroutine, $stdout, undef;
# Display STDOUT, capture STDERR
capture &subroutine, undef, $stderr;
capture_exec()
($stdout, $stderr, $success, $exit_code) = capture_exec(@args);
Captures and returns the output from "system(@args)". In scalar context, "capture_exec()" will return what was printed to "STDOUT". In list
context, it returns what was printed to "STDOUT" and "STDERR" as well as a success flag and the exit value.
$stdout = capture_exec('perl', '-e', 'print "hello world"');
($stdout, $stderr, $success, $exit_code) =
capture_exec('perl', '-e', 'warn "Test"');
"capture_exec" passes its arguments to "system()" and on MSWin32 will protect arguments with shell quotes if necessary. This makes it a
handy and slightly more portable alternative to backticks, piped "open()" and "IPC::Open3".
The $success flag returned will be true if the command ran successfully and false if it did not (if the command could not be run or if it
ran and returned a non-zero exit value). On failure, the raw exit value of the "system()" call is available both in the $exit_code
returned and in the $? variable.
($stdout, $stderr, $success, $exit_code) =
capture_exec('perl', '-e', 'warn "Test" and exit 1');
if ( ! $success ) {
print "The exit code was " . ($exit_code >> 8) . "
";
}
See perlvar for more information on interpreting a child process exit code.
capture_exec_combined()
($combined, $success, $exit_code) = capture_exec_combined(
'perl', '-e', 'print "hello
"', 'warn "Test
"
);
This is just like "capture_exec()", except that it merges "STDERR" with "STDOUT" before capturing output.
Note: there is no guarantee that text printed to "STDOUT" and "STDERR" in the subprocess will be appear in order. The actual order will
depend on how IO buffering is handled in the subprocess.
qxx()
This is an alias for "capture_exec()".
qxy()
This is an alias for "capture_exec_combined()".
SEE ALSO
o IPC::Open3
o IO::Capture
o IO::Utils
o IPC::System::Simple
AUTHORS
o Simon Flack <simonflk _AT_ cpan.org> (original author)
o David Golden <dagolden _AT_ cpan.org> (co-maintainer since version 1.04)
COPYRIGHT AND LICENSE
Portions copyright 2004, 2005 Simon Flack. Portions copyright 2007, 2008 David Golden. All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
perl v5.10.1 2010-02-15 IO::CaptureOutput(3pm)