public static void main(String[] args) throws Exception {
new RpcInfoCommand().execute(args);
}
public void execute() {
OncRpcPortmapClient client = null;
String hostname = argHost.getValue();
PrintWriter out = getOutput().getPrintWriter();
PrintWriter err = getError().getPrintWriter();
try {
InetAddress host = InetAddress.getByName(hostname);
client = new OncRpcPortmapClient(host, OncRpcProtocols.ONCRPC_UDP);
OncRpcServerIdent[] servers = client.listServers();
out.printf(fmt_list_serv, str_program, str_version, str_protocol, str_port, str_name);
out.println();
for (OncRpcServerIdent server : servers) {
out.printf(fmt_list_serv, server.program, server.version,
server.protocol == 6 ? str_tcp : str_udp,
server.port, getName(server.program));
out.println();
}
} catch (OncRpcException e) {
err.format(err_call, hostname);
exit(1);
} catch (UnknownHostException e) {
err.format(err_host, hostname);
exit(1);
} catch (IOException e) {
err.format(err_connect, hostname);
exit(1);
} finally {
if (client != null) {
try {
client.close();
} catch (OncRpcException e) {
// Ignore exception on close
}
}
}