ãé¡ã®ã¨ããã§ããå¦çãçµãã£ãããGrowlãã¡ã¼ã«ã§éç¥ãããã
ã¡ãã£ã¨æéã®ãããå¦çããã£ã¦ãã¦ãçµãã£ãããã¡ã¼ã«ã§éç¥ãã¦ã»ãããddã¨ããã
éç¥ããã¢ã¤ãã£ã¢
ãã£ã¨ãæãã¤ãã®ã¯ãããªæãã§ä½¿ããã¨ãã§ããããããã¡ãªãã ã
$ ./command | gmail $ ./command | growl $ gmail_notify ./commmand $ growl_notify ./command
ããããä¾ã¯ããæãã¤ããµã³ãã«ãå¤ãããã§ããã¼
èµ·åãå¿ãããçµããã
ãã®æ¸ãæ¹ã ã¨èµ·åãå¿ããæã«å¤§å¤ãä»ã«ãæã£ã以ä¸ã«æéãããã£ããï¼ã¿ãããªã¨ãã«å¯¾å¿ã§ããªãã
ããã»ã¹ç£è¦ã£ã½ãããã¾ãã
processçªå·ãç£è¦ãã¦ãããã»ã¹ãæ¶ãããã¡ã¼ã«ãéãããã«ãã¦ã¿ãã
ãããªæãã§ä½¿ãããã
$ ./gmail_notify PID:ããã»ã¹ID
ããã ã¨ããã¨ããããã»ã¹IDãå
ã«éç¥ãä½ãããããå¹
åºã使ãããã
growlã©ãããã®ï¼ï¼
Growlã¯ã»ã»ã»Gmailãç£è¦ãã¦ãã°ãããã§ãï¼
gmailã«ã¡ã¼ã«æ¥ãâGrowléç¥ããã
ã¡ã¼ã«ãéãã¨iPhoneãªã©ããã¤ã¹ã§ãéç¥ãããã®ã§ã絶対ã¡ã¼ã«ã®ã»ãã便å©ã
ã¡ã¼ã«éç¥è¨å®ãã¦ããã°ãé£éã§ç°¡åãããã§çµäºã§ããã
ããã»ã¹çªå·ãç£è¦ããã
#!/usr/bin/env ruby #å¦çãçµãã£ãããã¡ã¼ã«ã§éç¥ãããã # http://d.hatena.ne.jp/takuya_1st/ require 'rubygems' require 'net/smtp' require 'base64' require 'tmail' require 'tlsmail' def send_gmail( body= nil ) mail = TMail::Mail.new mail.to = "[email protected]" mail.from = "[email protected]" mail.subject = "å¦ççµäº" mail.date = Time.now mail.mime_version = "1.0" mail.set_content_type "text", "plain", {"charset" => "iso-2202-jp"} t = Time.now.strftime("%Y-%m-%d %H:%M:%S") mail.body = "å¦ççµäº (#{t})" unless body Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) Net::SMTP.start( "smtp.gmail.com", 587, "local","[email protected]â,â***PASS***","plain" ){|smtp| smtp.sendmail( mail.encoded,mail.from,mail.to ) } end def still_alive?( proccess_id ) `ps #{proccess_id}`.split(/\n/).size >1 end def watch( process_id) while( still_alive? process_id) do sleep 60 end end puts "Usage : #{__FILE__} PROCESS_ID " if ARGV.size < 0 exit if ARGV.size < 0 watch( ARGV.shift) send_gmail()
ããã¯ã»ãã¨ãã«æ£ããã®ãããããªãã
Linuxã·ã¹ãã ã³ã¼ã«ã®ããã»ã¹ç£è¦ã»ç®¡çãããã§æ£ãããããããã©ãã¨ãããããããã£ã¨åãããããã¨ããã