Coverage report

| %line | %branch
--- | --- | ---
examples.rexec |
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.RExecClient;
20 |  |
21 |  |
     /***
22 |  |
      * This is an example program demonstrating how to use the RExecClient class.
23 |  |
      * This program connects to an rexec server and requests that the
24 |  |
      * given command be executed on the server.  It then reads input from stdin
25 |  |
      * (this will be line buffered on most systems, so don't expect character
26 |  |
      * at a time interactivity), passing it to the remote process and writes
27 |  |
      * the process stdout and stderr to local stdout.
28 |  |
      * <p>
29 |  |
      * Example: java rexec myhost myusername mypassword "ps -aux"
30 |  |
      * <p>
31 |  |
      * Usage: rexec <hostname> <username> <password> <command>
32 |  |
      * <p>
33 |  |
      ***/
34 |  |
35 |  |
     // This class requires the IOUtil support class!
36 | 0 |
     public final class rexec
37 |  |
     {
38 |  |
39 |  |
         public static final void main(String[] args)
40 |  |
         {
41 |  |
             String server, username, password, command;
42 |  |
             RExecClient client;
43 |  |
44 | 0 |
             if (args.length != 4)
45 |  |
             {
46 | 0 |
                 System.err.println(
47 |  |
                     "Usage: rexec <hostname> <username> <password> <command>");
48 | 0 |
                 System.exit(1);
49 | 0 |
                 return ; // so compiler can do proper flow control analysis
50 |  |
             }
51 |  |
52 | 0 |
             client = new RExecClient();
53 |  |
54 | 0 |
             server = args[0];
55 | 0 |
             username = args[1];
56 | 0 |
             password = args[2];
57 | 0 |
             command = args[3];
58 |  |
59 |  |
             try
60 |  |
             {
61 | 0 |
                 client.connect(server);
62 |  |
             }
63 | 0 |
             catch (IOException e)
64 |  |
             {
65 | 0 |
                 System.err.println("Could not connect to server.");
66 | 0 |
                 e.printStackTrace();
67 | 0 |
                 System.exit(1);
68 | 0 |
             }
69 |  |
70 |  |
             try
71 |  |
             {
72 | 0 |
                 client.rexec(username, password, command);
73 |  |
             }
74 | 0 |
             catch (IOException e)
75 |  |
             {
76 |  |
                 try
77 |  |
                 {
78 | 0 |
                     client.disconnect();
79 |  |
                 }
80 | 0 |
                 catch (IOException f)
81 | 0 |
                 {}
82 | 0 |
                 e.printStackTrace();
83 | 0 |
                 System.err.println("Could not execute command.");
84 | 0 |
                 System.exit(1);
85 | 0 |
             }
86 |  |
87 |  |
88 | 0 |
             IOUtil.readWrite(client.getInputStream(), client.getOutputStream(),
89 |  |
                              System.in, System.out);
90 |  |
91 |  |
             try
92 |  |
             {
93 | 0 |
                 client.disconnect();
94 |  |
             }
95 | 0 |
             catch (IOException e)
96 |  |
             {
97 | 0 |
                 e.printStackTrace();
98 | 0 |
                 System.exit(1);
99 | 0 |
             }
100 |  |
101 | 0 |
             System.exit(0);
102 | 0 |
         }
103 |  |
104 |  |
     }
105 |  |

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