From: Richard Kettlewell on
Tom Anderson <twic(a)urchin.earth.li> writes:
> Oh, that reminds me of another one that came up today. I have three
> scripts, stop, prepare, and start; i need to run stop and prepare
> before i can run start, but i can run stop and prepare in parallel. I
> can write a master script:
>
> stop &
> prepare
> wait
> start
>
> But the exact set of commands is fairly ad-hoc, due to changing
> parameters and whatnot, so writing a script seems like overkill. Is
> there a way to do this on the command line? This:
>
> stop &; prepare; wait; start
>
> Fails, apparently because the & needs to be the last thing on the
> line, and a ; doesn't count as end of line. This:
[...]

";" and "&" act as separators not (just) terminators. e.g.:

$ sleep 1 & echo spong ; wait ; echo done
[1] 93002
spong
[1]+ Done sleep 1
done
$

http://bit.ly/aK0vLZ

--
http://www.greenend.org.uk/rjk/
From: Tom Anderson on
On Wed, 3 Mar 2010, Richard Kettlewell wrote:

> Tom Anderson <twic(a)urchin.earth.li> writes:
>> Oh, that reminds me of another one that came up today. I have three
>> scripts, stop, prepare, and start; i need to run stop and prepare
>> before i can run start, but i can run stop and prepare in parallel. I
>> can write a master script:
>>
>> stop &
>> prepare
>> wait
>> start
>>
>> But the exact set of commands is fairly ad-hoc, due to changing
>> parameters and whatnot, so writing a script seems like overkill. Is
>> there a way to do this on the command line? This:
>>
>> stop &; prepare; wait; start
>>
>> Fails, apparently because the & needs to be the last thing on the
>> line, and a ; doesn't count as end of line. This:
> [...]
>
> ";" and "&" act as separators not (just) terminators. e.g.:
>
> $ sleep 1 & echo spong ; wait ; echo done
> [1] 93002
> spong
> [1]+ Done sleep 1
> done
> $

Aaaaaaaaaah. Or to put it in terms of the misunderstanding i was labouring
under: in the case of a single command being run in the background, & is
the terminator, not the carriage return. Yes, that solves my problem
entirely, thanks.

tom

--
alle Menschen werden Br