我正在尝试自动回答我的SSM文档中的Y,该文档使用shell脚本。

huangapple go评论50阅读模式
英文:

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 it automatically, I tried to add << - Y at the end of the command, but 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!'"
英文:

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!'"

答案1

得分: 1

有一个选项可以做到这一点:

sudo apt autoremove --yes nessusagent

查看 man apt-get

英文:

There's an option for that

sudo apt autoremove --yes nessusagent

See man apt-get

答案2

得分: 0

以下代码帮助我解决了提示问题。

echo 'Y' | sudo apt autoremove nessusagent
英文:

The below code helped me to get over with the prompt.

echo &#39;Y&#39; | sudo apt autoremove nessusagent

huangapple
  • 本文由 发表于 2023年6月12日 23:20:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76458075.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定