1

I want to install a package (dnf install package) through python using subprocess. While installing the package the terminal will ask for a Y/N. mine is an automation script and it should directly use y without user input. how to pass the 'Y' parameter without user input.

1
  • Not a real programming question, more about using commandline tools. Check the help of your tool for an argument to skip the prompt or alternatively use a pipe from the yes command (man yes). Commented Aug 17, 2021 at 5:46

1 Answer 1

2

I don't know your install code, but something like below would work.

import subprocess
subprocess.run(["dnf", "install", "packagename", "-y"])

For example, I can list files by

import subprocess
subprocess.run(["ls", "-l"])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.