Coverage report

  %line %branch
examples.rlogin
0% 
0% 

 1  
 /*
 2  
  * Copyright 2001-2005 The Apache Software Foundation
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package examples;
 17  
 
 18  
 import java.io.IOException;
 19  
 import org.apache.commons.net.bsd.RLoginClient;
 20  
 
 21  
 /***
 22  
  * This is an example program demonstrating how to use the RLoginClient
 23  
  * class. This program connects to an rlogin daemon and begins to
 24  
  * interactively read input from stdin (this will be line buffered on most
 25  
  * systems, so don't expect character at a time interactivity), passing it
 26  
  * to the remote login process and writing the remote stdout and stderr
 27  
  * to local stdout.  If you don't have .rhosts or hosts.equiv files set up,
 28  
  * the rlogin daemon will prompt you for a password.
 29  
  * <p>
 30  
  * On Unix systems you will not be able to use the rshell capability
 31  
  * unless the process runs as root since only root can bind port addresses
 32  
  * lower than 1024.
 33  
  * <p>
 34  
  * JVM's using green threads will likely have problems if the rlogin daemon
 35  
  * requests a password.  This program is merely a demonstration and is
 36  
  * not suitable for use as an application, especially given that it relies
 37  
  * on line buffered input from System.in.  The best way to run this example
 38  
  * is probably from a Win95 dos box into a Unix host.
 39  
  * <p>
 40  
  * Example: java rlogin myhost localusername remoteusername vt100
 41  
  * <p>
 42  
  * Usage: rlogin <hostname> <localuser> <remoteuser> <terminal>
 43  
  * <p>
 44  
  ***/
 45  
 
 46  
 // This class requires the IOUtil support class!
 47  0
 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  0
         if (args.length != 4)
 56  
         {
 57  0
             System.err.println(
 58  
                 "Usage: rlogin <hostname> <localuser> <remoteuser> <terminal>");
 59  0
             System.exit(1);
 60  0
             return ; // so compiler can do proper flow control analysis
 61  
         }
 62  
 
 63  0
         client = new RLoginClient();
 64  
 
 65  0
         server = args[0];
 66  0
         localuser = args[1];
 67  0
         remoteuser = args[2];
 68  0
         terminal = args[3];
 69  
 
 70  
         try
 71  
         {
 72  0
             client.connect(server);
 73  
         }
 74  0
         catch (IOException e)
 75  
         {
 76  0
             System.err.println("Could not connect to server.");
 77  0
             e.printStackTrace();
 78  0
             System.exit(1);
 79  0
         }
 80  
 
 81  
         try
 82  
         {
 83  0
             client.rlogin(localuser, remoteuser, terminal);
 84  
         }
 85  0
         catch (IOException e)
 86  
         {
 87  
             try
 88  
             {
 89  0
                 client.disconnect();
 90  
             }
 91  0
             catch (IOException f)
 92  0
             {}
 93  0
             e.printStackTrace();
 94  0
             System.err.println("rlogin authentication failed.");
 95  0
             System.exit(1);
 96  0
         }
 97  
 
 98  
 
 99  0
         IOUtil.readWrite(client.getInputStream(), client.getOutputStream(),
 100  
                          System.in, System.out);
 101  
 
 102  
         try
 103  
         {
 104  0
             client.disconnect();
 105  
         }
 106  0
         catch (IOException e)
 107  
         {
 108  0
             e.printStackTrace();
 109  0
             System.exit(1);
 110  0
         }
 111  
 
 112  0
         System.exit(0);
 113  0
     }
 114  
 
 115  
 }
 116  
 

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.