Advertisement
Guest User

Untitled

a guest
Jun 9th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.14 KB | None | 0 0
  1. # Connect to the legcy system
  2. Net::SSH.start( legacyIp, legacyUsername,
  3.                 :password => legacyPassword,
  4.                 :port     => legacyPort
  5.                 ) do |session|
  6.   # Show we're connected
  7.   puts "....Connected!\n"
  8.  
  9.   session.open_channel do |channel|
  10.  
  11.     legacyHostname = (session.exec! findHostNameCmd).delete("\n")
  12.     currentTimestamp = Time.now.strftime("%d%m%Y%H%M%S")
  13.     puts session.exec! findHostNameCmd
  14.     blueprintName = legacyHostname + "-" + currentTimestamp
  15.     # puts "" + legacyHostname + "-" + currentTimestamp
  16.    
  17.     blueprintCmd = createBlueprintCmd + " " + blueprintName
  18.     print blueprintCmd + "\n"
  19.  
  20.     channel.exec(blueprintCmd) do |ch, success|
  21.       abort "could not execute command" unless success
  22.  
  23.       channel.on_data do |ch, data|
  24.         puts "got stdout: #{data}"
  25.         channel.send_data "something for stdin\n"
  26.       end
  27.  
  28.       channel.on_extended_data do |ch, type, data|
  29.         puts "got stderr: #{data}"
  30.       end
  31.  
  32.       channel.on_close do |ch|
  33.         puts "channel is closing!"
  34.       end
  35.     end  
  36.  
  37.     # print "Create blueprint repo" + "\n"
  38.  
  39.   end
  40.  
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement