I need some help here. I have a log file that gets updated every hour approximately.
I want to make some processing on each line which is added in the log file with a program written in PERL.
The problem is that I don't see anything when a line is added in the log file.
I use the tail command on my log file piped to my PERL program :
Here is a sample of the log file :
And here is my program :
To understand what I want to see for the output let's take an example. If this line was added to the log file nothing should happen because it is not a VOP type :
Whereas, if this line was added :
Here is what I should see as an output if the filename is log1:
That's it. I don't get any output with the tail command. Does anyone see an error there or has an idea of what I am doing wrong here ?
The "tail -f" command never ends, it continuously reads if there is a new line added to the log file and if there is one when you pipe it to a program that reads the STDIN it gets this new line.
I am sure of what I am saying beacause I have tested it before making this program.
The thing is, I don't understand where is the problem here.
Are you sure that the regex is correct (I didn't test it)?
Other than that, you're printing without a newline at the end, so any output probably gets buffered. Either add a "\n" to the end, or disable output buffering by setting $| to 1.
Are you sure that the regex is correct (I didn't test it)?
Other than that, you're printing without a newline at the end, so any output probably gets buffered. Either add a "\n" to the end, or disable output buffering by setting $| to 1.
Hi pludi,
Yes the regular expression is correct. It gives me exactly what I want, I have tested it. I will try to the "\n" at the end and let you know if it worked.
Thanks
---------- Post updated at 11:36 AM ---------- Previous update was at 10:58 AM ----------
Quote:
Originally Posted by pludi
Are you sure that the regex is correct (I didn't test it)?
Other than that, you're printing without a newline at the end, so any output probably gets buffered. Either add a "\n" to the end, or disable output buffering by setting $| to 1.
Sorry but, how do I do to say that the thread is solved ??
Hey pludi, it works. I would never had thought that a missing "\n" would cause the whole thing to not work.
Hi,
I want to read extended ASCII characters from keyboard using c language on unix/linux. How to read extended characters from keyboard or by copy-paste in terminal irrespective of locale set in the system. I want to read the input characters from keyboard, store it in an array or some local... (3 Replies)
Hello,
When I am trying to use tail +13 filename.csv it is throwing an error.
tail: cannot open `+13' for reading: No such file or directory and then prints last 10 lines of the file. (File is present on the path)
But when i try tail -13 filename.csv it runs perfectly.
Could I have... (5 Replies)
Hey,
I want to create a new file (devices) with the 39th and the 40th character of the line wich is in the array line and in the file drivers.
But unfortunately my try doesn't work:
sed -n '$linep' drivers | cut -c 39-40 | echo >>devices Perhaps one of you can help me. Thank you!
emoly
... (0 Replies)
tar has the -T operand for reading patterns from a file.
Is there any way to read patterns from stdin, without creating a temp file? I would like to avoid iterating over the archive repeatedly (e.g. with a loop or xargs) as this is a large archive and we're only extracting a small number of... (2 Replies)
Hi All,
How I will read the output of the tail -F command in perl.
I have text file with below contains
file1.txt
1
2
3
4
$running=1;
sub openLog($)
{
(my $log) = @_; (1 Reply)
Hi,
i am using the below program to read from the standard input or to write to standard out put.
i know that using highlevel functions this can be done better than what i have done here.
i just want to know is there any other method by which i find the exact number of characters ( this... (3 Replies)
This is going to be part of a longer script with more features, but I have boiled it down to the one thing that is presently stumping me. The goal is a script which checks for updates to web pages that can be run as a cron job. The script reads (from a tab-delim file) a URL, an MD5 digest, and an... (1 Reply)
Hello all,
I've got what I'm pretty sure is a simple problem, but I just can't seem to work past it. I'm trying to use awk to pretty up a log file, and calculate a percentage.
The log file looks like this:
# tail strtovrUsage
20090531-18:15:45 RSreq - 24, RSsuc - 24, RSrun - 78, RSerr -... (4 Replies)
Not sure why this does not work in bash:
tail -f err.log |&
-bash: syntax error near unexpected token `&'
I am attempting to continuously read a file that is being updated by doing a "tail -f" on the file and piping the output to stdin which can then be read by the next shell command
Thnx (4 Replies)
Hi. Im using cat to output the contents of a file, then piping it to my while read loop.In this loop variables get assigned values. However when i try to use the variables outside the loop their values has been reset.I understand about subshells etc. but I have no idea how to "preserve" the... (3 Replies)