Search code examples
shellaws-ssm

I am trying to answer Y to my SSM document automatically that uses shell script


The line "sudo apt autoremove nessusagent" asks for prompt Y/n I always have to say Y. Trying to find a way to do automatically I tried to add <<- Y at the end of the command it didn't work.


schemaVersion: "2.2" description: "Command Document Example JSON Template" parameters: Message: type: "String" description: "Hello World!" default: "Hello" mainSteps:

  • action: "aws:runShellScript" name: "HelloScript" inputs: runCommand:
    • "sudo apt autoremove nessusagent &&"
    • "sleep 20 &&"
    • "echo 'uninstallation completed!'"

Solution

  • There's an option for that

    sudo apt autoremove --yes nessusagent
    

    See man apt-get