linux - How can i tell Java code run the script as it was running from command line as normal user? -


when run script manually browser chrome open site in 1 tab (which perfect how needed)

but when run same script using java sample code 10 times, open browser 10 times same page 10 tabs.

q. how can tell java code please run suppose running manual execution (so have 1 tab only?) ?

bash: /var/tmp/runme.sh (ran 1o times , still have 1 tab expected)

export display=:0.0 ps aux | grep chromium-browser | awk '{ print $2 }' | xargs kill -9; sleep 8; chromium-browser --process-per-site --no-discard-tabs --ash-disable-tab-scrubbing -disable-translate "http://www.oracle.com" & 

java: launch 10 times script

  system("/var/tmp/runme.sh &");    public static string system(string cmds) {     string value = "";     try {       string cmd[] = { "/bin/sh", "-c", cmds};       process p = runtime.getruntime().exec(cmd);       p.waitfor();       bufferedreader reader = new bufferedreader(new inputstreamreader(p.getinputstream()));       string line = reader.readline();       while (line != null) {         value += line + "\n\r";         line = reader.readline();       }     }      catch (ioexception ioe) {       ioe.printstacktrace();     }      catch (interruptedexception ie) {       ie.printstacktrace();     }     return value;   } 

fist remove & line system("/var/tmp/runme.sh &");

second, maybe since, using this: "/bin/sh", java running script different shell every time invoke using runtime?

and executing /var/tmp/runme.sh same shell everytime.

note: /bin/sh interpreter , java runtime invoking multiple instances of execute script every time.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -