reading a text files as a UNIX command writes to it
reading a text files as a UNIX command writes to it
- Subject: reading a text files as a UNIX command writes to it
- From: Richard Covert <email@hidden>
- Date: Tue, 1 Jun 2004 15:42:56 -0500
One of the nice things about UNIX is the 'tail -f <file>' command. It
copies the last line of a text file to standard output as it is
written. So,
if your UNIX command reports progress by writing to stdout
peridioically, you can redirect its output to a file (2>&1 > File), and
then
do a "tail -f <file>' to monitor the output.
Given, that I have a program written in C++ that reports the progress
of by sending out messages such as
line1
line2
.
.
.
lineXX
I would like to capture these lines as they appear in the UNIX text
file and send them to a 'text view of scroll view'
object in my window 'main'.
So, the problem is that I would have do an idle loop and read the
output file every 30 seconds or so, until
I get a line that I know is the last line (lineXX if I know what XX is
in advance).
But, this approach has a couple of problems. First, it blocks the
current AS script. SEcond, it uses valuable CPU cycles.
I don't want to add an OS C interface to my C++ code before I can use
it in my AS script. I could add a GUI to the program
and then just let it run as another MAc OS X App, but that will
requires some additional coding. I can use the program as it if
I don't mind calling it as a command line driven program.
So,
what is a good way to capture a text file in AS and write it to a text
view AS the file is being filled by a UNIX command??
Thanks
Ohm BTW, 'tail -f' does not quit unless you manually kill it, just for
what its worth.
bye
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.