Created
September 8, 2010 17:19
-
-
Save Whoops/570440 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
require 'net/ssh' | |
print "Enter host: " | |
host=gets.chomp | |
print "Enter username: " | |
user=gets.chomp | |
print "Enter password: " | |
password=gets.chomp | |
Net::SSH.start(host, user, :password => password) do |ssh| | |
channel = ssh.open_channel do |ch| | |
ch.exec "iptables -L" do |ch, success| | |
raise "error running command" unless success | |
#stdout | |
ch.on_data do |c, data| | |
puts data | |
end | |
#stderr | |
ch.on_extended_data do |c, type, data| | |
puts data | |
end | |
ch.on_close { puts "work complete!" } | |
end | |
channel.wait | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment