LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to read individual logs from Linux server into another log file (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-read-individual-logs-from-linux-server-into-another-log-file-883929/)

indra4647 06-01-2011 07:06 AM

How to read individual logs from Linux server into another log file
 
I am new in perl, i have a question i.e 'How to read individual logs from linux server into another log file using perl script', I need to capture the individual logs from different paths and output the result of those log files and store to a file in another location.These Logs are generated in Linux Server..

theNbomr 06-01-2011 10:30 AM

You use two conflicting terms: 'read' and 'capture', which I interpret with quite different meanings. Are you trying to simply open() and read() pre-existing files in a post-processing scenario? Or, are you trying to read data in some kind of real-time scenario (like what 'tail -f' does)?
In either case, for creating the output file(s), you need to simply open() for writing (either over-write or append as appropriate to you) the target file, write() your data, and then close() the file.
If your question is simply about the use of particular perl functions, then I think I have given you enough hints to get you started. For the details of any particular function call:
Code:

perldoc -f functionName
#
#  eg
#
perldoc -f write

--- rod.

chrism01 06-01-2011 10:51 PM

See also http://perldoc.perl.org/, http://www.perlmonks.org/?node=Tutorials & this for realtime (equiv of tail -f) http://search.cpan.org/~mgrabnar/Fil...0.99.3/Tail.pm


All times are GMT -5. The time now is 05:17 AM.