lib/ssh/manager/cli.rb in ssh-manager-1.1.3 vs lib/ssh/manager/cli.rb in ssh-manager-1.1.4

- old
+ new

@@ -107,20 +107,20 @@ def transfer_key(id) #TODO connect_via #TODO options id.each do |con| - connection = DATABASE.get_connection_by_id(con) + connection = DATABASE.get_connection_by_id(con.to_i) user = connection[:user] user = ENV['USER'] if user == "" %x(ssh-copy-id #{user}@#{connection[:ip]}) end end def ping(id) id.each do |con| - connection = DATABASE.get_connection_by_id(con) + connection = DATABASE.get_connection_by_id(con.to_i) if connection[:connect_via] connect_via = DATABASE.get_connection_by_id(connection[:connect_via]) ssh = "ssh #{connect_via[:user]}@#{connect_via[:ip]}" exec("#{ssh} ping #{connection[:ip]} -c 3") else @@ -131,11 +131,11 @@ def execute_command(id) # id.first should be the command cmd = id.shift id.each do |con| - connection = DATABASE.get_connection_by_id(con) + connection = DATABASE.get_connection_by_id(con.to_i) if connection[:connect_via] connect_via = DATABASE.get_connection_by_id(connection[:connect_via]) ssh = "ssh #{connect_via[:user]}@#{connect_via[:ip]}" system("#{ssh} #{cmd}") else @@ -205,12 +205,11 @@ #TODO catch SQLite3::ConstraintException end def delete(id) id.each do |conn| - conn.to_i - DATABASE.delete_connection(conn) + DATABASE.delete_connection(conn.to_i) end end def list_all connections = DATABASE.get_connection_data @@ -222,10 +221,10 @@ end end def update(id) id.each do |con| - connection = DATABASE.get_connection_by_id(id) + connection = DATABASE.get_connection_by_id(con.to_i) @input_fields.each do |key| #TODO make this a method connection[key] = %x{source #{File.dirname(__FILE__)}/ask.sh; ask '#{@pretty_names[key]}' '#{connection[key]}'}.chomp end connection[:connect_via] = nil if connection[:connect_via] == ""