Ahmed Khan Ahmed Khan - 8 months ago 115
Java Question

Run multiple commands on processbuilder in same session of sub process

I am trying to run unix commands using java Processbuilder. It creates sub processes each time new command is given. How can i run all commands in same session ?
I am trying to implement
1. & - puts job in background
2. Fg (id) brings job in foreground
3. Jobs - display current background processes in same terminal.

How can I achieve this ?


Best way to run command simultaneously is put all command in one scrip file an and then run that script file using Processbuilder

You can pass parameters as well.

$ cat myscript
echo "First arg: $1"
echo "Second arg: $2"
$ ./myscript hello world
First arg: hello
Second arg: world