13 lines
361 B
Ruby
Executable file
13 lines
361 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
require 'open-uri'
|
|
|
|
open('http://whatismyip.com') do |f|
|
|
puts "Open failed: #{f.status.inspect}" unless f.status.first == "200"
|
|
# <TITLE>WhatIsMyIP.com - 207.81.136.119</TITLE>
|
|
title = f.gets while title !~ /<TITLE>WhatIsMyIP\.com - (\d[\d.]+)</
|
|
ip = $1.chomp
|
|
ENV['SHELL'] = '/bin/bash'
|
|
`echo -n "#{ip}" | pbcopy`
|
|
puts ip
|
|
end
|