I'm trying to automate the installation of CUDA on an Ubuntu 18.04 VM template as part of the startup script. I'm very new to bash and cloud computing in general. When I run the command to install CUDA, mid-installation I am always prompted to choose a country and a language from a list of options by entering the corresponding ID numbers.
Basically, when I run:
sudo apt-get -y install cuda
I know I'm going to have to manually enter "31" and "1" for the install to complete. As a relative n00b at all this, my question is thus "How do I automate those inputs so I don't have to manually type them in every time I spin up a fresh copy of this VM template?"
My initial approach was this:
printf "31\n1\n" | sudo apt-get -y install cuda
But this does not seem to work the way I expected it to. No input is autofilled.
My end goal is to have everything taken care of in one startup script that I don't have to touch.
I appreciate any and all help, and I apologize if my question has been answered elsewhere (if it has, I've been unable to find it and would greatly appreciate being directed to it!)
expect
(one of them is the accepted answer). Also, in both questions the users want the same thing: use a script to enter input in multiple prompts. The only difference is stated in the body (not in the title) of the linked question, which is that the user wants to enter "yes" to every prompt, but in my opinion doesn't suffice to making it not a duplicate. – BeastOfCaerbannog Oct 15 '20 at 20:45