title: rmi java program not expected output
body: <p>The rmi program when run asks a command.</p>
  
  <p>If I gave ipconfig it works,but does not works for ping www.google.com and powercfg/batteryreport etc. I think it does not works if their is a space or slash between the input command.</p>
  
  <p>Any help would be appreciated</p>
  
  <p>si.java  </p>
  
  <pre><code> import java.rmi.*;
   import java.net.*;
   import java.io.*; 
  
   public interface si extends Remote{
        public String calc(String com) throws RemoteException,IOException;
   }
  </code></pre>
  
  <p>imp.java</p>
  
  <pre><code>  import java.rmi.*;
    import java.rmi.server.*;
    import java.util.*;
    import java.net.*;
    import java.io.*;
  
    public class imp extends UnicastRemoteObject implements si{
  
    imp() throws RemoteException,IOException {
        super();
    }
  
    public String calc(String com) throws IOException{
        String inputLine;
        Runtime r=Runtime.getRuntime();
        Process p=r.exec(com);
        BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
  
        while((inputLine = in.readLine()) != null) {
            System.out.println(inputLine);
            //pingResult += inputLine;
        }
  
        return inputLine;
     }
  
  }
  </code></pre>
  
  <p>server.java</p>
  
  <pre><code>  import java.rmi.*;
    import java.rmi.registry.*;
  
    public class server{
         public static void main(String args[]){
             try{
                 si stub=new imp();
                 Naming.rebind("rmi://localhost:5000/example",stub);
             } catch(Exception e) {
             }
         }
   }
  </code></pre>
  
  <p>client.java</p>
  
  <pre><code>import java.rmi.*;
  import java.util.*;
  public class client{
      public static void main(String args[]){
         try{
               si a=(si)Naming.lookup("rmi://localhost:5000/example");
               Scanner s=new Scanner(System.in);
               System.out.println("enter command");
               String com=s.next();
               System.out.println(a.calc(com));
               } catch(Exception e){
               }
        }
  }
  </code></pre>