Skip

Stop Bash from getting ahead of itself...
December 6, 2008 1:09 PM   Subscribe

Shell scripting quandry: running apt-get and then running a command that requires a apt-get installed package fails because bash doesn't wait for apt-get to finish...

My first approach is running a shell script that runs the installation, and I've had this problem. The code is like

apt-get install blah blah blah python-setuptools
easy_install libxml

However, bash runs apt-get and doesn't wait for it to finish before running the easy_install line - and the easy_install line requires setuptools to be installed. Currently I've just split the script into two scripts at that point, so that this little timing issue doesn't come up. But that's a workaround and I'm frustrated that there isn't a better way. Using 'wait' isn't working because apt-get is interactive...

Bonus points if you can point to a way that shell scripts can just install the most recent version of a package without specifying exactly what it is in the name? My issue is that this is for Ubuntu 7-8 and I don't want it to fail because of differences in repository versions...

Thanks! I'm a bit of a shell-scripting noob, and writing a robust install script for this project (Mapnik) is a big challenge.
posted by tmcw to Computers & Internet (4 answers total)
 
&&
posted by holgate at 1:15 PM on December 6, 2008


apt-get whatever args && easy_install foobar

In an 'and list', a command following && are executed only if the command preceding the && returned zero (which indicates success).

The list can be arbitrarily long: this && that && hic && hoc.
posted by orthogonality at 1:18 PM on December 6, 2008


Awesome, that's exactly what I needed. Thanks guys.
posted by tmcw at 1:39 PM on December 6, 2008


[apt-get|aptitude] -y may help - also, you could check $? as needed, though && is the easiest.

The most robust way here is to then check for the install status of python-setuptools rather than depending on apt exiting 0 to indicate successful install.
posted by kcm at 4:13 PM on December 6, 2008


« Older Does anyone know of a clinic w...   |  My girlfriend received a lette... Newer »
This thread is closed to new comments.


Post