# Parallel process in bash scripts.



## valsorym (Aug 2, 2011)

*Bash - parallel process.*

Hi all.
I wrote script automation install GUI. He has next lines:

```
. . .
which openbox | awk '{print "exec " $1}' > $HOME/.xinitrc
	
Xorg â€“configure
Xorg â€“config /root/xorg.conf.new â€“retro

cd /root/
cp xorg.conf.new /etc/X11/xorg.conf
```

But, after run 

```
Xorg â€“config /root/xorg.conf.new â€“retro
```
run GUI and script stops. Last two commands do not run.
I must click (Ctrl+Alt+F2), login, and manually carry them out.

How can I be?

Thank you.


----------



## fonz (Aug 2, 2011)

doorways said:
			
		

> ```
> Xorg â€“configure [red](1)[/red]
> Xorg â€“config /root/xorg.conf.new â€“retro[red](2)[/red]
> ```
> ...


Actually, it doesn't "stop". You started a new process (line 2) in the foreground so your script waits for that to finish (in other words, it waits for your X session to terminate).

I suggest you do the file copying between both Xorg commands (i.e. between lines 1 and 2).

Hope this helps,

Fonz


----------



## valsorym (Aug 3, 2011)

> Originally Posted by *fonz*
> Actually, it doesn't "stop". You started a new process (line 2) in the foreground so your script waits for that to finish (in other words, it waits for your X session to terminate).



Yes. I thought so. My English is a little weak. I could not describe the situation - opened only the essence. But thank you.



> Originally Posted by *fonz*
> I suggest you do the file copying between both Xorg commands (i.e. between lines 1 and 2).



This is not an exit with the situation.
1. Why copy _/root/xorg.conf.new_ until run command _Xorg-config /root/xorg.conf.new-retro_?
2. At the end of the script will be added to command _shutdown-r now_.
With this decision, it will fail.

How can I start a new process without suspending the script?


----------



## fonz (Aug 3, 2011)

doorways said:
			
		

> How can I start a new process without suspending the script?


Add an ampersand (&) to the end of the line:

```
Xorg â€“config /root/xorg.conf.new â€“retro [b][red]&[/red][/b]
```
However, if you add a shutdown(1) command after that, it will kill everything off, which might not be what you want either.

Fonz


----------



## valsorym (Aug 3, 2011)

> Originally Posted by *fonz*
> Add an ampersand (&) to the end of the line:



Oh, yes. It seems it works. Thank you. Thank you very much.
I close this theme when it's going to work on this script.

Tested as follows:
1. Run OpenBox
2. Created a script


```
#!/bin/sh
#

xterm &
xterm &
# end file.
```
After performing to run two terminals - the parent console continues to be responsible. Thank you.


----------

