Last active
December 28, 2015 18:29
-
-
Save kfei/7543514 to your computer and use it in GitHub Desktop.
This file contains 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
def get_interface_name | |
interfaces = {} | |
puts 'Valid network interfaces detected are:' | |
interfaces_with_mac = `ifconfig -a | grep -i hwaddr | awk '{ if( match($1, /^eth/) ) {print $1, $5} }'`.lines.map(&:chomp) | |
interfaces_with_mac.each_with_index do |x, index| | |
interfaces[index] = x.split[0] | |
puts " #{index}) #{x.split[0]} ( #{x.split[1]} )" | |
end | |
print 'Please choose an interface to configure: ' | |
interface_to_configure = gets.chomp!.to_i | |
interfaces[interface_to_configure] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment