Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Inside String you can provide your script which is you are running through terminal </p> <pre><code>import java.io.BufferedReader; import java.io.InputStreamReader; public class Multipleprocess { public static void main(String[] args)throws Exception { int process=0; String s[]={"/bin/sh","-c","cat /etc/*-release" }; Process p=Runtime.getRuntime().exec(s); BufferedReader proc=new BufferedReader(new InputStreamReader(p.getErrorStream())); BufferedReader pout=new BufferedReader(new InputStreamReader(p.getInputStream())); // We read stderror first from String because it spits the progress information //into stderr for (String s1=proc.readLine(); s1!=null; s1=proc.readLine()) { process++; System.out.println("Stderr from p: "+s); } for (String s1=pout.readLine(); s1!=null; s1=pout.readLine()) { process++; System.out.println("Stdout from p: "+s); } //how many process have completed check here System.out.println("process have completed"+process); // if you need to check whether the command actually returned normally int returnCode = p.waitFor(); proc.close(); pout.close(); System.out.println("Process exited with return code "+returnCode); } } </code></pre> <p>I have checked my programme it running on my eclipse, you can use my programme,I got output like this:</p> <pre><code>Stderr from p: [Ljava.lang.String;@186d4c1 Stderr from p: [Ljava.lang.String;@186d4c1 Stderr from p: [Ljava.lang.String;@186d4c1 Stderr from p: [Ljava.lang.String;@186d4c1 process have completed16 </code></pre> <p>Process exited with return code 0 You can see here process completed 16</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload