Reading in real time from a file without pipes

Stephen Montgomery-Smith stephen at math.missouri.edu
Fri Jan 5 00:32:25 UTC 2007


Matthew Hudson wrote:
> Mon Dec 11 09:08:37 PST 2006 c0re dumped wrote: 
> 
>>I wonder if is possible to read data from a
>>certain file without using a pipe.
>>
>>Let me explain:
>>
>>I have a process already writing messages to
>>a logfile. I want to read all written data
>>(without neither stop nor interfere normal
>>log process) from another process in real
>>time.
>>
>>How can I achieve it ?
> 
> 
> When on the command line, I do this using the program 'socat'
> (net/socat in ports). I.e.
> 	socat FILE:/var/log/messages,ignoreeof -
> 
> This gives me the same sort of behavior as 'tail -f' except that
> it reads the entire file in first.  I also use this when I'm
> say scp'ing over a really large tarball of text files and want
> to start looking at the files as they're coming in: 
>     * bigdir.tgz is a big tarball being scp'd over, 3 hours remaining *
> 
> 	socat FILE:bigdir.tgz,ignoreeof - | gzip -dc | tar xf - &
> 
> and just like that I now have bigdir.tgz being expanded in realtime
> without having to do anything that may have interfered with the scp (such
> as using ssh to run 'tee' on the remote host and do it that way.

Wouldn't "tail -f +1" do the same thing?



More information about the freebsd-hackers mailing list