3

My script is replacing sysvinit with systemd inside a chroot while building a debian image with debootstrap.

Since this is a "dangerous" action, apt-get will ask a silly question: "To continue type in the phrase 'Yes, do as I say!'"

How can I script the reply to that?

EDIT: I tried all the -y --yes --force-yes options, but they don't work.

5

Strangely, it seems asked even with --force-yes:

apt-get remove -y --force-yes systemd

However,

echo 'Yes, do as I say!' | apt-get remove systemd

worked neatly.

| improve this answer | |
0

apt-get has a -y, --yes, --assume-yes switch:

       Automatic yes to prompts; assume "yes" as answer to all prompts and
       run non-interactively. If an undesirable situation, such as
       changing a held package, trying to install a unauthenticated
       package or removing an essential package occurs then apt-get will
       abort. Configuration Item: APT::Get::Assume-Yes.

or, in alternative a --force-yes switch:

       Force yes; this is a dangerous option that will cause apt to
       continue without prompting if it is doing something potentially
       harmful. It should not be used except in very special situations.
       Using force-yes can potentially destroy your system! Configuration
       Item: APT::Get::force-yes

http://manpages.ubuntu.com/manpages/utopic/man8/apt-get.8.html

| improve this answer | |
  • I should have mentioned that I tested that, but it did not work. will update Q. – Lennart Rolland May 29 '15 at 23:03
  • Ok, no problem, at the moment I'm not on a debian based system so I can't try my solution on my own and recognize it doesn't work. – lgaggini May 29 '15 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.