Capture data in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture data in a file
# 1  
Old 06-16-2008
Capture data in a file

How to capture the rows in a file after executing the store procedure using the perl scripts?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to capture last 15mins data logged from server.log file?

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

Capture the data in Linux .While doing load test.

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

Capture a block of data

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

How to compare data from 2 zip files and capture the new records from file2 to a new file

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

capture data from matched string/line

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

Creating a printer emulator to capture PDL/PCL data coming in on port 9100.

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

Capture two set of data to same line...simple

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

capture output of file and send last string thereof to new file

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

Howto capture data from rs232port andpull data into oracle database-9i automatically

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

Capture POST data

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
Login or Register to Ask a Question
IO::Capture::Overview(3pm)				User Contributed Perl Documentation				IO::Capture::Overview(3pm)

NAME
IO::Capture -- Overview of "IO::Capture" Module, and classes derived from it. DESCRIPTION
The modules in this distribution are designed to allow you to capture and process output sent to STDOUT and/or STDERR. I initial created the modules to use in building module tests. I wanted to be able to intentionally cause errors, and insure the module responded correctly. E.g., Call a class method without a required argument. Using IO::Capture keeps the user from seeing these inten- tional errors when running 'make test'. I have also found this useful on occasion in Perl Tk apps, where I wanted to capture output from a Perl module I was using. I could then capture, then put the text into a log or message window. Note: None of the modules currently distributed will capture from the 'system' Perl function, or the like. It could be done, but gener- ally, if you would like to capture from a system command, you don't need this module, just use the backticks operators. my $output = '/usr/bin/ls'; They are small, lightweight modules. Instead of designing in a lot of features, we designed it to be easily reusable and adaptable. A module can be quickly built, that incorporates custom methods, but reuses all existing features of one of the derived classes. See the sec- tion on "ADDING FEATURES" Or, if you need to change the actual capture mechanism, "WRITING YOUR OWN DERIVED CLASS". (Don't worry, it's a piece of cake) DERIVED CLASSES
There are several classes derived from "IO::Capture". IO::Capture::Stdout Module to capture "STDOUT" from program. See IO::Capture::Stdout. IO::Capture::Stderr Module to capture "STDERR" from program. See IO::Capture::Stderr. IO::Capture::ErrorMessages This method has been depreciated. The only difference between this one and Stderr.pm was the trap for WARN. I found it was fixed in 5.8 so just check in Stderr now. I.e., Just use Stderr now. It (Stderr) will detect what version of perl you are using, and act accordingly. The two ("IO::Capture::ErrorMessages" and "IO::Capture::Stderr") are currently identical, and "IO::Capture::ErrorMessages" will be removed in a future release. If you would like to add features to any of these, or build your own module using "IO::Capture" as a base, read on. ADDING FEATURES
If one of these modules takes care of your problem, install it and have fun! But let's say you would like to add a feature to one of the derived classes, say IO::Capture::Stdout. No need to re-write the whole mod- ule, just use it as the base, and write your one feature. Here is a somewhat simplified example. # # Example module to add a grep_it method # # Give your package a name package MyPackage; #use IO:Capture:Stdout as the base use base 'IO::Capture::Stdout'; #define your method sub grep_it { my $self = shift; my $string = shift; my @found_lines; # Making a ref to the array makes it easier to read :-) my $arrayref = @{$self->{'IO::Capture::messages'}}; for my $line (@$arrayref) { push @found_lines, $line if $line =~ /$string/; } return wantarray ? @found_lines : scalar(@found_lines); } 1; Using it in this script #!/usr/sbin/perl use strict; use warnings; use MyPackage; my $capture = MyPackage->new(); $capture->start; print "The quick brown fox jumped over ..."; print "garden wall"; print "The quick red fox jumped over ..."; print "garden wall"; $capture->stop; for my $line ($capture->grep_it("fox")) { print "$line "; } Results in $ grep_it The quick brown fox jumped over ... The quick red fox jumped over ... WRITING YOUR OWN DERIVED CLASS
Before starting your own sub-class, be sure to read through IO::Capture. Pay special attention to the internal methods that are only defined as abstract methods in "IO::Capture". For examples, look at the sub-classes included with this distribution. ("IO::Capture::Std- out", "IO:Capture::Stderr". You can start by copying one of these and using it as a template. They have the required private methods defined already, and you may very well be able to use them as is. Change any methods, and add any new ones, as needed. For example, here is a commented copy of "IO::Capture::Stderr". # # Example module using abstract class IO::Capture # # Change this to give your class it's own name package IO::Capture::Stderr; # Make IO::Capture the base class use base qw/IO::Capture/; # If using included utility module in '_start()' use IO::Capture::Tie_STDx; # Override the three abstract methods needed to make a valid # module. See IO::Capture manpage # 1) _start - Starts the data capture. Is run from public method # start(); # # 2) _retrieve_captured_text() - Move the captured text into the # object hash key, "IO::Capture::messages". Called by public method # # 3) _stop - Stop the data capture. Called by public method 'stop()' # after private method '_retrieve_captured_text()' returns. # sub _start { tie *STDERR, "IO::Capture::Tie_STDx"; } sub _retrieve_captured_text { my $self = shift; # making a reference to it makes it more readable ;-) my $messages = @{$self->{'IO::Capture::messages'}}; @$messages = <STDERR>; } sub _stop { untie *STDERR; return 1; } 1; Lets say you don't want to capture all the text. You just want to grab the lines that have the word "Error" in them. The only thing you need to change is _retrieve_captured_text. (Besides the package name) Something like: sub _retrieve_captured_text { my $self = shift; # making a reference to it makes it more readable ;-) my $messages = @{$self->{'IO::Capture::messages'}}; while (<STDERR>) { push @$messages, $_ if /error/i; } } Yes. You could do this easier by just using "IO::Capture::Stderr" as the base and overriding "_retrieve_captured_text" like in "ADDING FEA- TURES", but hey, we needed an easy example. :-) If you want your class to have arguments that users can pass in, just use the default "new()" method and have the arguments passed in as an anonymous array. See the "IO::Capture::Stderr" module for an example. BUGS
Please report bugs on http://rt.cpan.org/ CREDITS
Special thanks to James E Keenan for many bug fixes and tests he provided. AUTHOR
Mark Reynolds reynolds<at>sgi.com Note: "Change <at" to 'at' sign.> COPYRIGHT
Copyright (c) 2003-2005, Mark Reynolds. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.8.8 2007-07-30 IO::Capture::Overview(3pm)