Can you paste the code, so i can check at my local.
Can you paste the code, so i can check at my local.
The code is above in #13, you can add and remove extra print statements as you need to help with debugging. That is one method I often use.
But text searching part [prod: pro: ] is not there? Can you please put that.
Or are you wanting the script to change its output when encountering that string?
Actually When script run that first find last 30 minutes of log file, so for example it greps 200 lines which have last 30 minutes of log. After that i wants to search "prod: pro:" in 200 lines, let suppose that text exist in 10 lines so only show those 10 lines discard 190 lines.
Would it work to pipe the output through grep then?
Code:./last30minoflogs.pl /var/log/syslog | grep "prod: pro:"
Yes Thanks so much, it is working you are cool. You are guru in perl, can you please suggest me so i can write perl scripts.
Perl is fun and very, very useful for running a system. I picked up just the basics some years ago with books using it at work, but it should be easy to pick up from a lot of sources.
If your college library has the book "Programming Perl" aka the Camel Book or the book "Learning Perl", that will help.
There are online sources. "Beginning Perl" is online free: http://www.perl.org/books/beginning-perl/ and then there are some tutorials : http://learn.perl.org/tutorials/
But above all, be comfortable looking up stuff in "man perlfunc" and the other builtin man pages. See "man perl" for the full list, divided by subject.
By the way, the module Date::Calc is from the archive CPAN which has many thousands of modules. If there is a function or activity you want, there is probably a module for it. A good portion of the CPAN modules are already available in Ubuntu via the repositories, so you can add them using the package manager.
Bookmarks