Topic: Need help assigning an IP address to a Varible
Hello to the ruby world I was hoping to get a bit of guidance... I
have the following code below that logs int to a cisco router and
performs a command:
HOST = '220.127.116.11'
USER = ''
PASS = ''
puts "Give me the ip address" #(user enters 18.104.22.168)
@ipadd = gets
Net::SSH.start( HOST, USER, :password => PASS ) do|ssh|
ssh.exec('sho ip route ' + @ipadd)
Below is the output form the above code (without the ##):
AMP_STL_Intra_SW4#sho ip route 22.214.171.124
Routing entry for ##126.96.36.199##/25
Known via "connected", distance 0, metric 0 (connected, via interface)
Routing Descriptor Blocks:
* directly connected, via Vlan307
Route metric is 0, traffic share count is 1
I would like to scan this output and assign only the IP address between
the ##'s to a variable for further use. I am new to programming so I'm
sure this is amateur Any help is mush appreciated.
Last edited by jallen (2012-02-21 13:42:54)