title: How to send a string to the terminal without having it to be a standard command?
body: <p>I am writing a program in Java that needs to use terminal command to work.
  My function basically looks like this : </p>
  
  <pre><code>public void sendLoginCommand() throws IOException
  {
      System.out.println("\n------------Sending Login Command------------\n");
      String cmd="qskdjqhsdqsd";
      Runtime rt = Runtime.getRuntime();
      Process p=rt.exec(cmd);
  }
  public Process sendPassword(String password) throws IOException
  {
      System.out.println("\n------------Sending Password------------\n");
      String cmd=password;
      Runtime rt = Runtime.getRuntime();
      Process p=rt.exec(cmd);
      return p;
  }
  public void login(String password) throws IOException
  {
      sendLoginCommand();
      Process p = sendPassword(password);
      System.out.println("\n------------Reading Terminal Output------------\n");
      Reader in = new InputStreamReader(p.getInputStream());
  
      in = new BufferedReader(in);
      char[] buffer = new char[20];
      int len = in.read(buffer);
      String s = new String(buffer, 0, len);
      System.out.println(s);
      if(s.equals("Password invalid.")) loggedIn=false;
      else loggedIn=true;
  }
  </code></pre>
  
  <p>Here, the program sends correctly th p4 login command, but then, the terminal asks for a password.
  When I use the same lines that with the sendLoginCommand(), the program returns an error.
  Apparently, we can send only standard commands throught Process.
  I was hoping that someone knew how to send a normal string to the terminal</p>
  
  <p>Thank you in advance</p>