2015-11-21 23:04:28 +04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2015-11-24 03:46:12 +04:00
|
|
|
# Exit early if no sessions with my username are found
|
|
|
|
exit unless `who -q`.include? ENV['USER']
|
2015-11-22 20:20:48 +04:00
|
|
|
|
2015-11-21 23:04:28 +04:00
|
|
|
require 'net/telnet'
|
|
|
|
|
|
|
|
coffee_machine_ip = '10.10.42.42'
|
|
|
|
password = '1234'
|
|
|
|
password_prompt = 'Password: '
|
2015-11-25 21:46:26 +08:00
|
|
|
delay_before_brew = 17
|
2015-11-23 09:57:25 -08:00
|
|
|
delay = 24
|
2015-11-21 23:04:28 +04:00
|
|
|
|
2015-11-25 21:46:26 +08:00
|
|
|
sleep delay_before_brew
|
2015-11-21 23:04:28 +04:00
|
|
|
con = Net::Telnet.new('Host' => coffee_machine_ip)
|
|
|
|
con.cmd('String' => password, 'Match' => /#{password_prompt}/)
|
|
|
|
con.cmd('sys brew')
|
2015-11-23 09:57:25 -08:00
|
|
|
sleep delay
|
2015-11-21 23:04:28 +04:00
|
|
|
con.cmd('sys pour')
|
|
|
|
con.close
|