Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need the folders to stick around and can't find a way to stop the script from removing them. It's supposed to install software, but is designed for RedHat and I want to compile and run the files manually within Ubuntu. Is there anyway to step through a bash script or extract an archive from a self install .sh file? Thanks!

The package in question is: http://irsa.ipac.caltech.edu/data/SPITZER/docs/dataanalysistools/tools/spice/downloadspice/ (The Linux .sh)

share|improve this question
1  
Could you edit your question and add the output of running the script without sudo like this ./spice2_5_0-linux.sh --help? –  Braiam Sep 24 '13 at 1:04
    
@Braiam In this case it doesn't function. The script inside is a basic one. It is possible to read with less and see what it does... and to act in a similar way. With an editor that respect the binary part (the second one) it's possible to modify the script part, e.g. to comment what you need not (in this case the lines with rm -f $outname_tar and rm -rf $tempdir). –  Hastur May 22 at 8:48

1 Answer 1

In this case you need only to do

tail -n +31  spice2_5_1-generic-linux.sh > spice2_5_1-generic-linux.tar

after you can deal with it as a normal tar file. ( tar -xvf spice2_5_1-generic-linux.tar).

Since this tar has not a main directory I suggest you to do

mkdir TempSpice   
cd TempSpice
tar -xvf ../spice2_5_1-generic-linux.tar

Some notes:

Often the self extracting files are a bash script followed by data, just in only one file. In this case the script is in the first 30 lines.

#!/bin/sh
PATH=/bin:/usr/bin
base=sut.$$
outname_tar=$base.tar
tempdir=spottmp.$$
mkdir $tempdir
echo "Unpacking..."
platform=`uname`
if [ $platform = "SunOS" ]; then
    tail +31 $0 > $outname_tar
else
    tail -n+31 $0 > $outname_tar
fi

echo "Extracting..."
(cd $tempdir; tar xvf ../$outname_tar)
  savestatus=$?
  if [ $savestatus != "0" ]; then
    echo status from tar = $savestatus
    echo ABORTING INSTALLATION
    /bin/rm -rf $tempdir
    /bin/rm -f $outname_tar
    exit $savestatus
    fi
echo "cleaning up..."
/bin/rm $outname_tar
echo "installing..."
(cd $tempdir; ./INSTALL)
/bin/rm -rf $tempdir
exit 0

The script inside is a basic one. It was possible to read the file with less and see what it does... and to act in a similar way. With an editor that respects the binary part (the second one) it's possible to modify the script part too.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.