0

Im trying to download git using a .sh file for vagrant but when it gives me the prompt to continue, it aborts automatically. This is the contents of my .sh file:

#!/usr/bin/env bash 

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git
git clone https://git.openstack.org/openstack-dev/devstack

How do I tell it to input yes at the correct time. I tried to do: echo "yes" after the install git line but that's too late

RalfFriedl
  • 8,816
  • 6
  • 23
  • 34
  • Is it the `-y`/`--yes`/`--assume-yes` flag for `apt-get` you're looking for? – Kusalananda Aug 30 '18 at 20:26
  • Also see [How to use Shellcheck](https://github.com/koalaman/shellcheck), [How to debug a bash script?](https://unix.stackexchange.com/q/155551/56041) (U&L.SE), [How to debug a bash script?](https://stackoverflow.com/q/951336/608639) (SO), [How to debug bash script?](https://askubuntu.com/q/21136) (AskU), [Debugging Bash scripts](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html), etc. –  Aug 30 '18 at 21:48

1 Answers1

0

If it aborts instead of asking, the script is not connected to a terminal.

From the apt-get manual:

-y, --yes, --assume-yes
Automatic yes to prompts. Assume "yes" as answer to all prompts and run non-interactively.

RalfFriedl
  • 8,816
  • 6
  • 23
  • 34
  • Okay. I got passed that. now im trying to run stack.sh from devstack but when I do, I get the error "cannot determine host ip address." I did try to go to the samples/local.conf file and set my HOST_IP but that didnt work either – QuestionAsker123 Aug 30 '18 at 21:07
  • @QuestionAsker123 Your script is not running `stack.sh`. If you have further issues that are not pure followup issues, then update your question. If this answer solves the problem as stated in the question, I suggest that you [accept it](https://unix.stackexchange.com/help/someone-answers). – Kusalananda Aug 31 '18 at 05:49