p******g 发帖数: 347 | 1 I want to write a program to read a log file output from another program.
The file could be quite large. And I just want to read the last updated
content in it. How to achieve that? c++/python/shell/java... any kind of
language is fine.
I am think of tail -f, but how to read the pipe of "tail -f log | " in a program? |
p******g 发帖数: 347 | 2 ok basically i am trying to do IPC. one way is to use named pipe. first use
makefifo to create a pipe, tail -f to the pipe, and read the pipe in my
program...
program?
【在 p******g 的大作中提到】 : I want to write a program to read a log file output from another program. : The file could be quite large. And I just want to read the last updated : content in it. How to achieve that? c++/python/shell/java... any kind of : language is fine. : I am think of tail -f, but how to read the pipe of "tail -f log | " in a program?
|
n******t 发帖数: 4406 | 3 popen
program?
【在 p******g 的大作中提到】 : I want to write a program to read a log file output from another program. : The file could be quite large. And I just want to read the last updated : content in it. How to achieve that? c++/python/shell/java... any kind of : language is fine. : I am think of tail -f, but how to read the pipe of "tail -f log | " in a program?
|
p******g 发帖数: 347 | 4 thx.
i came across this
for perl, there's a File:Tail extension: see the link
http://www.softwareplug.com/Linux/man/File::Tail
for python, see
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/436477
【在 n******t 的大作中提到】 : popen : : program?
|
f**y 发帖数: 138 | 5 while not just C functions fopen, ftell, fseek, fread, and fclose? |
T*****9 发帖数: 2484 | 6 用一个while读,然后用一个足够长的buffer hold你读出来的东西,每读一次更新
什么语言都可以,推荐用python,或者perl更快
program?
【在 p******g 的大作中提到】 : I want to write a program to read a log file output from another program. : The file could be quite large. And I just want to read the last updated : content in it. How to achieve that? c++/python/shell/java... any kind of : language is fine. : I am think of tail -f, but how to read the pipe of "tail -f log | " in a program?
|
n**a 发帖数: 104 | 7 If the log file is on the SAME machine,and the operating system is Windows,
the most efficient way is to use Memory Mapped File, i.e., map the data file
into the address space of you process. |
T*****9 发帖数: 2484 | 8 in linux, it is mmap, hehe
,
file
【在 n**a 的大作中提到】 : If the log file is on the SAME machine,and the operating system is Windows, : the most efficient way is to use Memory Mapped File, i.e., map the data file : into the address space of you process.
|
|