1

This install script is giving me the error Unable to locate package for most of the programs.

#! /bin/bash

apps=(
'python-dev',
'python-pip',
'python-numpy',
'python-scipy',
'python-matplotlib',
'ipython',
'ipython-notebook',
'python-pandas',
'python-sympy',
'python-nose',
'python-picamera',
'openssh-client',
'openssh-server',
'vim'
)

sudo apt-get update

# Loop over apps and install each one with default 'yes' flag
for app in "${apps[@]}"
do
    sudo apt-get install $app -y
done 

# configure ssh
sudo cp /etc/ssh/sshd_confi /etc/ssh/sshd_config.original
sudo chmod a-w /etc/ssh/sshd_config.original

piplist=(
'networkx',
'scikit-image'
)

for app in "${piplist[@]}"
do
    sudo pip install -U $app
done 

It only installed vim. So I imagine that my repo-list is not updated but I thought that is what 'sudo apt-get update' was for.

When I ran sudo apt-get install python-dev, outside the script it did install the package.

  • 1
    Please post the exact error message you are getting.. – heemayl Mar 13 '15 at 17:34
  • @heemayl Definetly – Liam Pieri Mar 13 '15 at 17:37
  • Looks like your $app gets the comma appended for other package names than vim. Try removing the commas from the apps sudo apt-get install $(echo $app | sed 's/,//g') -y instead of sudo apt-get install $app -y – Milind Dumbare Mar 13 '15 at 17:44
  • Unable to locate package..what is the name of the package that is showing in the error message? The answer is in the name.. – heemayl Mar 13 '15 at 17:52
  • 1
    @Miline, thank you very much this was the solution! – Liam Pieri Mar 13 '15 at 18:01
1

Looks like your $app gets the comma appended for other package names than vim. Try removing the commas from the apps

or Try

sudo apt-get install $(echo $app | sed 's/,//g') -y

instead of

sudo apt-get install $app -y

and

sudo pip install -U $(echo $app | sed 's/,//g')

instead of

sudo pip install -U $app
0

Miline's answer that I should replace sudo apt-get install $app -y with sudo apt-get install $(echo $app | sed 's/,//g') -y was the solution.

  • You can also remove the trailing comma , from each member of the array..in that case you don't need any modified install command.. – heemayl Mar 13 '15 at 18:05
  • posted my answer :-) – Milind Dumbare Mar 13 '15 at 18:08
  • @Miline Yeah I posted it thinking I could close the question but then I realized I had to wait two days. – Liam Pieri Mar 14 '15 at 4:55
0

You can remove all the trailing commas (,) following each member of the array so that you don't need any additional modification to your apt-get install command. So, your script could look like:

#!/bin/bash

apps=(
'python-dev'
'python-pip'
'python-numpy'
'python-scipy'
'python-matplotlib'
'ipython'
'ipython-notebook'
'python-pandas'
'python-sympy'
'python-nose'
'python-picamera'
'openssh-client'
'openssh-server'
'vim'
)

sudo apt-get update

# Loop over apps and install each one with default 'yes' flag
for app in "${apps[@]}"
do
    sudo apt-get install $app -y
done 
  • Thanks I didn't know that the commas were optional this will make the script easier to write – Liam Pieri Mar 14 '15 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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