bash scripting: eval and waiting for processes in background
Dave Howorth
dhoworth at mrc-lmb.cam.ac.uk
Thu Feb 25 15:29:36 UTC 2010
Amedee Van Gasse (ub) wrote:
> Hi,
>
> I have a directory with some scripts with similar names, that I would like
> to run. I would like to run them all from another script, without having
> to specify their individual names. Because in the future I may add other
> scripts, and then I don't have to change the master script.
> I tried this:
>
> SCRIPTS=`ls /root/bin/hotcopy-*.sh`
> eval "$SCRIPTS" &
> wait
> echo "Continue master script."
> I suspect that the problem is with the eval command parsing multiple
> scripts at once. I tried moving the & inside the quotes, but that doesn't
> make a difference.
You need an & for each command you want to run in the background. It
would be join(' & ', @SCRIPTS) in Perl but I don't remember the bash
syntax. Or you could use a for loop to start each script with an &
Cheers, Dave
More information about the ubuntu-users
mailing list