bash - opening a shell and interact with using Java -


I had already asked the question, but with no replies, but this problem is similar and again with something Other questions have been found No proper answer Can anyone help me with this I am trying to open a shell from Java and interact with it (read the command and write the output of the shell) Changing the commands directory , A C program etc. Shcit not be provided by the user or compile.

I also tried and use the / bin / bash -c method and have the following as well.

  process p = new process builder ("extram"). Start (); Process P = New process builder ("/ bin / bash") Start ();   

Thank you and I hope the problem is clear.

itemprop = "text">

The example of a practical solution will be almost like the bottom

  process ; RT = Runtime.GetRight (); Try {Process = rt.exec (new string [] {"bash", "-c", "ls -al / home /"}}; log.Warn ("message to display"); BufferedReader input = New BufferedReader (new InputStreamReader (process.getInputStream ()); String line = faucet; while ((line = input .readline ()) = null {log.Warn (line);} Int exitVal = process.waitFor ( ); Log.warn ("exits error code:" + exitVal);} hold (IOException e) {log.warn ("IO Execption 1 ho:" + e.getMessage ());} hold (exception e ) {Log. Warn ("Execution:" + e.getMessage ());}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -