I have 3 concerns:
1)By sending output of program to a text file, you mean modify the
No. If it outputs to stdout, you could easily redirect it to a file. Try
typing “Foo.exe > myfile.txt”. This overwrites myfiles.txt with the
output from Foo.exe. If you want do append to the file instead of
overwriting, do “Foo.exe >> myfile.txt”. Works exactly the same on *nix
2)And if I were to modify the binary and send all outputs to a text file
and not stdout, how do I specifically read just the last lines that were
added, instead of rereading the whole file from the top.
If you need just the last line, you could read the file into a string,
filecontents = get_file_contents_somehow()
lastline = filecontents.split( /\n/ ).last
you could create an array of lines with
lines = filecontents.split( /\n/ )
- How do I do an update every few seconds using AJAX and how would I
update it without redisplaying the entire file, but rather just the new
lines that were added to the file.
Look at the prototype helpers, they’re documented in the rails api.