1

I want to create a bash script (called install_conda.sh), which installs Anaconda Cloud on my Ubuntu. I have downloaded the package using wget, i can make it run, but there are some things i can't figure out how to do.

  1. 1st thing after i run the anaconda script is: "In order to continue the installation process, please review the license agreement.Please, press ENTER to continue". How do make my install_conda.sh to press that Enter?

  2. After pressing enter, another thing appears: "Do you approve the license terms? [yes|no]". Here, i must type yes, and then press Enter. Again, how to do this?

  3. Now, this thing appears: "Anaconda3 will now be installed into this location: /path/to/anaconda3 Press ENTER to confirm the location". Again i must press Enter...

  4. In the end, i have to type yes again, for this: Do you wish the installer to prepend the Anaconda3 install location to PATH in your /home/whatev/.bashrc ? [yes|no]".

2 days searching google didn't help. I've read something about an xdotool, but i want to avoid installing other stuff from the Internet, so bash only please.

Thanks in advance :)

mathB
  • 634
  • 8
  • 21
David Botezatu
  • 159
  • 2
  • 3
  • 11
  • 1
    Have you tried `expect`? [Check this](https://stackoverflow.com/questions/7729948/expect-script-issue) – mathB Oct 24 '17 at 12:15
  • As far as i know, in order to use `expect`, i have to install it first. I would like to avoid that, since the script might be used on computers without Internet access. – David Botezatu Oct 24 '17 at 12:35
  • @tripleee, I can see why you marked this as duplicate, however, I find the answer is quite different from those you linked. It might be worth having this around and perhaps OP can re-word the original question to add some value to it. Just some thoughts... – Oliver Baumann Oct 24 '17 at 13:25

2 Answers2

7

I am posting another answer, as this is probably closer to what you want.

Anaconda has a "silent install" option. From the example on that page:

wget http://repo.continuum.io/miniconda/Miniconda3-3.7.0-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
Oliver Baumann
  • 2,209
  • 1
  • 10
  • 26
1

yes does this for you nicely! As for sending Enter, can you try sending the newline character \n?

Something like this perhaps:

#!/bin/bash
yes | bash Anaconda3-4.2.0-Linux-x86_64.sh
Oliver Baumann
  • 2,209
  • 1
  • 10
  • 26
  • Can you give me a precise example please? My script looks like this: `$!/bin/bash bash /tmp/Anaconda3-5.0.0.1-Linux-x86_64.sh` – David Botezatu Oct 24 '17 at 12:37
  • 1
    @DavidBotezatu `yes | install_conda.sh` – Aserre Oct 24 '17 at 12:39
  • @Aserre it doesn't work... if i do `yes | install_conda.sh` it tells me `install_conda.sh: command not found` – David Botezatu Oct 24 '17 at 12:48
  • @DavidBotezatu your script will be named differently. BTW, are you simply trying to automate running the default Anaconda installation script? Or have you actually **written** a script? If so, please post it! – Oliver Baumann Oct 24 '17 at 12:56
  • @DavidBotezatu you must run it in this way: yes | bash install_conda.sh or: yes | ./install_conda.sh if your script have permissions. – Darby_Crash Oct 24 '17 at 12:59
  • @OliverBaumann I am trying to automate the installation of Anaconda3-5.0.0.1-Linux-x86_64.sh - basically skip all those "Press enter" and "type yes" steps. – David Botezatu Oct 24 '17 at 13:05