英文:
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 'Y' | sudo apt autoremove nessusagent
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论