Skip to content

Instantly share code, notes, and snippets.

@shawn42
Created July 17, 2009 23:30
Show Gist options
  • Save shawn42/149345 to your computer and use it in GitHub Desktop.
Save shawn42/149345 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
filename = '/Users/sanderson/tmp/foo.txt'
class FileRat
def self.rat_tail(filename)
file = File.open filename
# end of file (fast-forward)
until file.eof?
str = file.readline
end
loop do
begin
until file.eof?
str = file.readline
if str =~ /uccess/i
msgstr = <<END_OF_MESSAGE
The thing worked! #{str}
END_OF_MESSAGE
require 'net/smtp'
Net::SMTP.start('mail.media.edmunds.com', 25) do |smtp|
smtp.send_message msgstr, 'sanderson@edmunds.com','sanderson@edmunds.com'
end
end
end
rescue EOFError => e
#
end
sleep 1
end
end
end
if $0 == __FILE__ do
FileRat.rat_tail ARGV[0]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment