[ale] Re: Simple bash question
Chuck Huber
chuck at cehuber.org
Mon Jan 28 18:19:31 EST 2008
> Message: 7
> Date: Mon, 28 Jan 2008 17:15:26 -0500
> From: "Doctor Who" <whodoctor at gmail.com>
> Subject: [ale] Re: Simple bash question
> To: "Atlanta Linux Enthusiasts" <ale at ale.org>
> Message-ID:
> <4b75340e0801281415q4709e6b7va5019be984859f70 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Jan 24, 2008 7:49 PM, Doctor Who <whodoctor at gmail.com> wrote:
>> > Hi All-
>> >
>> > On a regular basis, I download code from CVS and then do the same
>> > steps to build. I have a directory that contains a number of other
>> > directories. I go into several of these directories (always the same
>> > ones) and do a:
>> >
>> > ./autogen.sh
>> > make
>> > **SWITCH TO ROOT AND THEN**
>> > make install
>> >
>> > I see the benefits in scripting this exercise. The flow is something like:
>> >
>> > cd directory
>> > $ ./autogen.sh
>> > $ make
>> > $ su -
>> > Password: XXX
>> > # make install
>> > #exit
>> > $ cd ../next_directory
>> > $ ./autogen.sh
>> > $ make
>> > $ su -
>> > Password: XXX
>> > # make install
>> > #exit
>> > $cd ../third_directory
>> >
>> > ...ETC...
>> >
>> > Just curious how this might be accomplished with a bash script. If
>> > there was an error kicked back at any step, it would be nice to say as
>> > such.
>> >
>> > Thanks for any help.
>> >
>
> Anyone??
>
#
# Shell script to build multiple directories
#
DIRS="dir1 dir2 dir3 dir4 ..."
#
# To find all the directories in the cwd, one could also:
# DIRS=$(ls -l | sed -e '/^d/!d' | awk '{print $8;}')
#
for dir in ${DIRS} ; do {
# run each build in its own shell to return to this dir.
# if any command within the sub-shell fails, this shell
# should also exit
( cd $dir ; \
./autogen.sh && \
make && \
su --command="make install" - ) \
|| exit 1
done
Hope this helps.
Enjoy,
- Chuck
More information about the Ale
mailing list