title: ruby output format
body: <p>I have the following code, which works fine. The problem is that I get the following output:</p>
  
  <p>Device ID: SEP1C17D3415659</p>
  
  <p>IP address: 10.2.3.101</p>
  
  <p><strong>I would like to get:</strong></p>
  
  <p>SEP1C17D3415659 10.2.3.101</p>
  
  <p>Thanks for your help</p>
  
  <hr>
  
  <pre><code>require 'net/telnet'
  require '/apps/dateformat'
  
  
  @tdate = Formatdate.new.mydate
  
  hosts = %w"SW3"
  
  
    hosts.each do |hostname|
  
          tn = Net::Telnet::new("Host" =&gt; "#{hostname}",
                                       "Timeout" =&gt; 10000,
                                       "Prompt" =&gt; /[$%#&gt;] \z/n)
  
          tn.cmd('String' =&gt;'user' , 'Match'=&gt;/Password:/) { |c| puts c }
          tn.cmd('String' =&gt;'password', 'Match'=&gt;/#/) { |c| puts c }
          tn.cmd('String' =&gt;'terminal length 0', 'Match'=&gt;/#/) { |c| puts c }
  
  
          File.open("/agents/#{hostname}-#{@tdate}-agents.txt",'w') do |o|
              run=tn.cmd('String' =&gt;'sh cd ne de | inc Device ID: | IP address:', 'Match'=&gt;/#/) { |c| puts c }
                          run.each_line do |re|
                          mac = re.match /Device ID: ([\S]+)/
                          #ip = re.match /([\S]+) address/
                          ip = re.match /IP address: ([\S]+)/
                          o.puts mac
                          o.puts ip
                      end
  
  
  
  
          end
  
  end
  </code></pre>