I create a small script that installs a set of linux paquets .

Strangely apt-get install always fails and tells me that the package have not been found. Here is my script:

#! /bin/bash
sudo apt-get install python-software-properties
sudo apt-get update
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get install xfce4 postgresql-9.0 pgadmin3 chromium-browser wine iftop

What can i do to fix this ?

Thanks .

link|improve this question
Can you post the results of sudo apt-get install --simulate xfce4 postgresql-9.0 pgadmin3 chromium-browser wine iftop ? – jdw Sep 28 '11 at 17:41
in fact it fail at the first line : – isoman Sep 28 '11 at 17:49
1  
How does it fail? I've tried apt-get --simulate install <the rest> and apt-get install --simulate <the rest> and both succeed on my machine. Can you post more info on how it is failing? Although, I have to say that both George and Shane have good points. You should try those first. – jdw Sep 28 '11 at 17:56
feedback

3 Answers

If you're trying to install something from that PPA repository, your apt-get update should happen after you add the repo, not before.

You'll want a -y on the potentially interactive steps, too.

link|improve this answer
feedback

First line of your script. Remove the space.

#!/bin/bash

Also what @Shane said: on a script you may want to use -y to automate the process.

Update
Have you run chmod +x scriptname before trying to run it? Can you please post the exact error you're getting?

link|improve this answer
This is only a convention, not mandatory. Quoting Dennis Ritchie, en.wikipedia.org/wiki/Sha-bang#History "To take advantage of this wonderful opportunity, put #! /bin/sh at the left margin of the first line of your shell scripts. Blanks after ! are OK." – Andrew Sep 29 '11 at 1:59
You're right, I double checked a simple bash script and it works both with a space between #! and /bin/sh as well without one. But @isoman mentioned that his script is failing in the first line so I thought he give it a try. We'll have to wait for his feedback. – George Tasioulis Sep 29 '11 at 9:33
feedback

also you should first update apt-get and then install so the script should look like

#! /bin/bash
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install python-software-properties
sudo apt-get install xfce4 postgresql-9.0 pgadmin3 chromium-browser wine iftop

next make the file executable

chmod 755 script
link|improve this answer
well i tried with this tiny script to isolate the problem: #!bin/bash apt-get install -y iftop . i get an error telling that it can't find the package . When i run this commmand manually it work fine . – isoman Sep 30 '11 at 11:35
feedback

Your Answer

 
or
required, but never shown

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