I wrote a python to download and install the software with one click, but when some programs are installed, I need to judge what to do with Y or N

clipboard.png
for example, in this case, is there any way to let python directly judge that there is a judgment, and automatically enter Y,
or how to scan these specified statements, use if to judge, and then automatically enter Y.

Aug.05,2021

python has a pexpect module that simulates user interactive input, but is relatively cumbersome to maintain and may not be generic because of environmental problems. So we'll think about it when we really don't have a confession.

you have many ways to avoid interaction:

  1. check whether the software developer provides the or software repository for the corresponding operating system, and deploy or install the corresponding software package directly through package manager (the best policy is preferred, for example, your XMPP, actually has a deb/rpm package installed)
  2. automatic deployment scripts maintained by official or third parties usually provide non-interactive options. Call the shell API to run non-interactive parameters, and you can also avoid problems due to interactive interruptions (best strategy)
  3. .
  4. compile and install. Usually, the process of compilation and installation is non-interactive, but it is difficult to maintain and usually does not make the preferred consideration (bad policy)
  5. expect/pexpect script. It is difficult to maintain and achieve versatility. Usually, there is really no way to reconsider. With this solution, you can't expect to run steadily in all environments (worst policy)
Menu