# File lib/rhc-common.rb, line 777
  def self.list_scaled_ports(rhc_domain, namespace, app_name, app_uuid, hosts_and_ports, hosts_and_ports_descriptions, debug=true)

    ip_and_port_simple_regex = /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:[0-9]{1,5}/

    ssh_host = "#{app_name}-#{namespace}.#{rhc_domain}"

    ssh_cmd = "ssh -t #{app_uuid}@#{ssh_host} 'rhc-list-ports'"

    puts ssh_cmd if debug

    Open3.popen3(ssh_cmd) { |stdin, stdout, stderr| 

      stdout.each { |line|
        line = line.chomp
     
        if ip_and_port_simple_regex.match(line)
          hosts_and_ports << line
        end
      }

      stderr.each { |line|
        line = line.chomp

        if line.downcase =~ /permission denied/
          puts line
          exit 1
        end
        
        if line.index(ip_and_port_simple_regex)
          hosts_and_ports_descriptions << line
        end
      }
    }

  end