Unix Technical Forum

shell script question

This is a discussion on shell script question within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I have a shell script that builds a bunch of source archives one after another. Here's an excerpt: echo ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 07:46 PM
chud
 
Posts: n/a
Default shell script question

I have a shell script that builds a bunch of source archives one
after another. Here's an excerpt:

echo Installing Sh-utils-2.0
tar -xzvf sh-utils-2.0.tar.gz
cd sh-utils-2.0
patch -Np1 -i ../sh-utils-2.0.patch
LDFLAGS="-static" ./configure --prefix=$LFS/static \
--disable-nls
make
make install
cd ..
rm -rf sh-utils-2.0/

echo Installing Tar-1.13
tar -xzvf tar-1.13.tar.gz
cd tar-1.13
patch -Np1 -i ../tar-1.13.patch
LDFLAGS="-static" ./configure --prefix=$LFS/static --disable-nls
make
make install
cd ..
rm -rf tar-1.13/

How do I trap errors from make, patch, etc., and exit the script
if there is an error?

TIA


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-18-2008, 07:46 PM
William Hunt
 
Posts: n/a
Default Re: shell script question

On Fri, 7 Nov 2003, chud wrote:

> I have a shell script that builds a bunch of source archives one
> after another. Here's an excerpt:
>
> echo Installing Sh-utils-2.0
> tar -xzvf sh-utils-2.0.tar.gz
> cd sh-utils-2.0
> patch -Np1 -i ../sh-utils-2.0.patch
> LDFLAGS="-static" ./configure --prefix=$LFS/static \
> --disable-nls
> make
> make install

[...]
> How do I trap errors from make, patch, etc., and exit the script
> if there is an error?



assuming yer running your script in a bash shell, (probably true),
you can use stuff like:

make install || ( echo "ERROR: $? make install" && exit 1 )

if you want to use lots of errortesting, it's handy to a have:

function errorexit () {
echo ERROR: $*
exit 1
}

then, yer script can simply say:

make install || errorexit $? make install


--
William Hunt, Portland Oregon USA

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-18-2008, 07:46 PM
chud
 
Posts: n/a
Default Re: shell script question

On Fri, 07 Nov 2003 12:30:58 -0800, William Hunt wrote:

>
> assuming yer running your script in a bash shell, (probably true),
> you can use stuff like:
>
> make install || ( echo "ERROR: $? make install" && exit 1 )
>
> if you want to use lots of errortesting, it's handy to a have:
>
> function errorexit () {
> echo ERROR: $*
> exit 1
> }
>
> then, yer script can simply say:
>
> make install || errorexit $? make install


Thanks much. That's what I was looking for.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:05 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com