Handling input confirmations in Linux shell scripting

前端 未结 4 1507
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 14:51

I\'m writing a Linux Shell Script to automate a few things I\'m doing on Ubuntu 11.04.

Basically, I\'m writing a shell script to install NGINX, MySQL, and PHP, and then

相关标签:
4条回答
  • For Apt, the correct answer is to "preseed" your debconf database with the correct parameters. If Debconf finds the answer from its database, it won't ask. See also http://www.debian-administration.org/articles/394

    0 讨论(0)
  • 2021-02-05 14:58

    Usually you can call such interactive programs with an option to automatically answer yes to all questions. For instance, you can call apt-get with -y. From the man page :

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

    0 讨论(0)
  • 2021-02-05 15:01

    Try Expect it might be what you are looking for.

    0 讨论(0)
  • 2021-02-05 15:08

    yes | ./script will answer y for everything.

    Otherwise, write a script that prints the answers you want, eg:

     echo N
     echo Y
     echo Y
    
    0 讨论(0)
提交回复
热议问题