1 16 package examples; 17 18 import java.io.IOException ; 19 import org.apache.commons.net.bsd.RLoginClient; 20 21 45 46 public final class rlogin 48 { 49 50 public static final void main(String [] args) 51 { 52 String server, localuser, remoteuser, terminal; 53 RLoginClient client; 54 55 if (args.length != 4) 56 { 57 System.err.println( 58 "Usage: rlogin <hostname> <localuser> <remoteuser> <terminal>"); 59 System.exit(1); 60 return ; } 62 63 client = new RLoginClient(); 64 65 server = args[0]; 66 localuser = args[1]; 67 remoteuser = args[2]; 68 terminal = args[3]; 69 70 try 71 { 72 client.connect(server); 73 } 74 catch (IOException e) 75 { 76 System.err.println("Could not connect to server."); 77 e.printStackTrace(); 78 System.exit(1); 79 } 80 81 try 82 { 83 client.rlogin(localuser, remoteuser, terminal); 84 } 85 catch (IOException e) 86 { 87 try 88 { 89 client.disconnect(); 90 } 91 catch (IOException f) 92 {} 93 e.printStackTrace(); 94 System.err.println("rlogin authentication failed."); 95 System.exit(1); 96 } 97 98 99 IOUtil.readWrite(client.getInputStream(), client.getOutputStream(), 100 System.in, System.out); 101 102 try 103 { 104 client.disconnect(); 105 } 106 catch (IOException e) 107 { 108 e.printStackTrace(); 109 System.exit(1); 110 } 111 112 System.exit(0); 113 } 114 115 } 116 117 | Popular Tags |