Created
July 17, 2009 23:30
-
-
Save shawn42/149345 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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, '[email protected]','[email protected]' | |
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