[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bash-bug
Subject:    Re: Job queing
From:       Mårten_Segerkvist <marten () segerkvist ! se>
Date:       2006-08-21 16:45:26
Message-ID: 44E9E326.10003 () segerkvist ! se
[Download RAW message or body]

Having discovering 'trap' I scripted this:

declare -a queue[]
function q() {
  queue[${#queue[@]}]="cd `pwd` && $@"
}
function runq() {
  if [ -n "$queue" ]; then
    local command=$queue
    queue=("${queue[@]:1}")
    bash -c "($command; kill -33 $$)" &
  fi
}
trap 'runq' 33

which works almost as intended...

Bob Proulx, 08/21/06 17:23:
> Mårten Segerkvist wrote:
>   
>> command1 &
>> %1 && command2 &
>> %2 && command3
>>
>> (where the second command line awaits the execution of the first etc.)
>>     
>
> In a script you can grab the process id of the last background job
> with $!.  Then you can wait for that job id.
>
>   command &
>   wait $! && command2 &
>   wait $! && command3 &
>
> Just an idea...
>
> Bob
>
>
>   




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic