How to write Yes command as a answer to this question? Thanks - windows

I am absolute beginner in coding. I took code from ChatGPT to install Anaconda. However, I stuck at last step. I tried almost all possible variants of yes. Could sb help me, pls? How I can write yes to last question? Thanks.
anaconda3 v2022.10 [Approved]
anaconda3 package files install completed. Performing other installation steps.
The package anaconda3 wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint):

To answer an interactive prompt that is being displayed by Chocolatey, type the letter enclosed in [...] that corresponds to the desired option, which in your case is y (for [Y]es), or - to also auto-confirm subsequent prompts, if any, during the installation at hand - a (for [A]ll - yes to all).
Case doesn't matter.
Press Enter to submit your choice.
To suppress (conceptually: auto-confirm) confirmation prompts, follow the guidance in the note you cite:
For a given installation command, add the -y option on its command line.
To persistently suppress confirmation prompts, for all future Chocolatey installation commands, run the following one-time command, from an elevated session (run as administrator):
choco feature enable -n allowGlobalConfirmation

Related

Auto confirm an apt prompt in Bash

I am trying to make a bash script that will auto confirm the apt prompt when installing a package.
Here is what I try to auto confirm, and yes, I already tried "-y".
sudo apt install matchbox-keyboard -y
My rasp is in french and it keeps telling me that "-y" isn't recognized. Of course, since my rasp is in french, the prompt gets confirmed when I write "O" instead of "Y", but since I want my script to work with every language, I am looking for a way to use "-y" even on a french machine.
Does anyone of you know how to force the english confirm on a foreign language machine ?
Thanks in advance !

Simulate "ENTER" key press in shell script

I want to automate the run of the ./configure command. When I normally run it, every time I have to press enter. I want to run this command from a shell script and I don't want it to wait for a user to press enter at each prompt for path. How do I achieve this ? I am using Ubuntu machine with bash shell. Thanks.
mdt-inference#ubuntu:~/MDT/mdst-libreoffice$ ./configure
Path to Office installation? [/usr/lib/libreoffice]
Path to Office SDK installation? [/usr/lib/libreoffice/sdk]
Note : I tried the below link but it does not work.
How to simulate two consecutive ENTER key presses for a command in a bash script?
I have used "yes" command already but when I run ./configure there are multiple prompts which are more than two. When I use "yes", it just supplies argument to the first prompt only
yes command can be used here (with just 2 enter key)
yes " " | head -2 | ./configure
In general, this should work.
yes | ./configure
You might check out the cram Python package:
https://pypi.python.org/pypi/cram
It's designed for straightforward automation of command-line apps, and I've been pleasantly surprised by how well it's worked for my needs so far.

interactive shell script for execution of sudo commands

I installed gcc 5.2 with gmp, mpfr and mpc, plus the isl and cloog optimizations, works perfectly. All prefixes are in /usr/local so that I have to sudomy make install's. I had to redo the same install on the computer of a friend, and now, I have to do it on another computer of mine... It's enough, so that I wrote a script. (And broke my "script whatever you have to do twice" rule.) My problem is that at some places of the script I have sudo make install commands, and that I don't want to run my script as admin.
How could I modify my script so that the following happens : before each sudo make install command one is asked to elevate permissions, and if one accepts, one is asked the root password, and then, sudo make install is executed, and after, the next commands are executed with "normal" permissions, until the next sudo make install, etc... ?
(I tagged make but the question is of course independant of it.)
sudo doesn't ask you for the root password, but your own; and it only does this when you haven't sudoed recently enough.
So just put sudo : at the top of the script: then it will ask for the password right away, and after it has been supplied, all the other sudo commands will execute without asking anything.

Applescript for macports repository maintenance

Cannot create a useful script for scheduling the macports update and upgrade weekly e.g..
I tried a tiny script here:
on run {input, parameters}
do shell script "sudo /opt/local/bin/port selfupdate && sudo /opt/local/bin/port upgrade outdated && sudo /opt/local/bin/port clean --all installed" user name "<username>" password "<password>" with administrator privileges
return input
end run
And put this into Automator
Then as it running, the window will be frozen and if anything returns during the run, it shows as an exception message.
Can you write a useful script to get things done?
Thanks for help!
I think you are better off looking into the cron utility, that nowadays must be explicitly enabled. For all what I know, you can also get hold of a utility named Cronnix, to set it up. Your other alternative is to use Launchctl, here there is a friendly user interface named Lingon, that you can buy from the appstore.
There will always be an error log from updating MacPorts, that you should really read. The other thing is that when some packages gets deprecated, or some conflict occurs, then the update command really will require you to interact, by moving stuff aside, so the approach of using something to update Macports isn't as favourable as it may seem.
How about creating a recurring calendar event reminding you to do it? :)
If you are really tenacious about getting this to work, then you'll have to use the do shell script with administrator privileges, and if you don't like the dialog with password, and username, then you can hardcode those into your automator action. You'll then have to let go of sudo, since the ´with administrator privileges` does that for you.
do shell script "your shell script without sudo" user name "hardcodedusername" password "hardcodedpassword" with administrator privileges

run bash script without input

I have written a bash script which installs a number of packages, however for each consecutive package installation i am promoted with the following message:
After this operation, 1,006 kB of additional disk space will be used.
Do you want to continue [Y/n]?
Is there a way of setting the default to Y so no user input is required? My script is expected to run at night without any intervention
thanks in advance
Two methods come to mind. The first (and better option) is to use the options in your package manager. For example:
apt-get install -y [YOUR_PACKAGE]
if you use apt (type apt-get install --help for more help there).
The second is more of a quick-'n-dirty one...use a pipe after yes:
yes | apt-get install [YOUR_PACKAGE]
which always brings a smile to my face :p
The latter option also answers yes to ALL other questions, which can be handy (errors etc.) but can be risky (which is the reason those questions are there in the first place!)
I think that message looks like you are using apt-get.
In that case you can use the flag --assume-yes or shorter: -y, which should automatically answer yes to that question without prompting the user

Resources