This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Parsing information from a file, real time.

Old posts that have not been replied to for several years.
Locked
b
bisbis

Parsing information from a file, real time.

Post by bisbis »

Hello, i've tried many ways but failed.
One part of my tcl script requires that it can parse data from a while, the second it is written to it.

Say we have file.log and i want the tcl script to open the file, and when a new line is written to it it outputs the line to a channel.

Is this possible at all?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Why just don't you report then write to file? The way you choose to go is like reinventing the wheel.. What you want to do with the write, read and report thing? Also, please do try to be more specific to get an better ideea of what you want to do and probably sugest you something even better.
Once the game is over, the king and the pawn go back in the same box.
b
bisbis

Post by bisbis »

caesar wrote:Why just don't you report then write to file? The way you choose to go is like reinventing the wheel.. What you want to do with the write, read and report thing? Also, please do try to be more specific to get an better ideea of what you want to do and probably sugest you something even better.
Thanks for your reply.

I need this because the data is written to the file by another script, which is not even done in tcl.

So basicly i want the tcl script to monitor the log file, and output every new line that is written to it
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Then how dose it know WHEN to read from the log file and paste the news? Also, can't you use an TCL script to do the same thing your "another script" is doing?
Once the game is over, the king and the pawn go back in the same box.
b
bisbis

Post by bisbis »

caesar wrote:Then how dose it know WHEN to read from the log file and paste the news? Also, can't you use an TCL script to do the same thing your "another script" is doing?
It should check the logfile every lets say 5 seconds.
It's not possible to redo the other script in tcl
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

How should it know what are thouse new lines? I't possible to complicate it a bit and make it remember the last line he read but.. why is not possible to make that script to TCL?
Once the game is over, the king and the pawn go back in the same box.
b
bisbis

Post by bisbis »

Because the other script is a shell script which asks for information from the user, then logs its action to a file.

There is a way to do this, because i've seen it in action but didnt see the code.

hmm, well maybe i could make it check if the filesize of the log gets bigger, compared to its previous filesize (this is done at the start of the script). And if the filesize is bigger, it does a tail -n1 to get the latest line
b
bisbis

Post by bisbis »

Problem solved, works like a dream.
d
difoo
Voice
Posts: 33
Joined: Sat Jul 03, 2004 9:56 am

Post by difoo »

How did you solve it? I'm looking for a similar script it seems impossible to do :-(
m
meij

Post by meij »

difoo wrote:How did you solve it? I'm looking for a similar script it seems impossible to do :-(
use a utimer (to check every 1-5 seconds) and what bisbis said
bisbis wrote:hmm, well maybe i could make it check if the filesize of the log gets bigger, compared to its previous filesize (this is done at the start of the script). And if the filesize is bigger, it does a tail -n1 to get the latest line
d
difoo
Voice
Posts: 33
Joined: Sat Jul 03, 2004 9:56 am

Post by difoo »

I'm not able to code it myself, that's why I was looking for an existing script. What it should do is parse the output from /var/log/httpd.conf in #mycastle everytime the logfile gets updated (via apache when a user access my website)

Any help would be appreciated.

-difoo
d
difoo
Voice
Posts: 33
Joined: Sat Jul 03, 2004 9:56 am

Post by difoo »

Anyone?
d
difoo
Voice
Posts: 33
Joined: Sat Jul 03, 2004 9:56 am

Post by difoo »

please, anyone can help?
N
NiTR8^
Voice
Posts: 2
Joined: Wed Mar 10, 2004 7:17 pm

Post by NiTR8^ »

difoo wrote:please, anyone can help?
Script sent in PM :)
Locked