我必须卸载一个软件,在卸载软件时,它会提示您按yes or no
寻找答案..给出以下示例。
# /opt/altiris/notification/nsagent/bin/aex-uninstall
This will remove the Symantec Management Agent for UNIX, Linux and Mac software from your system.
Are you sure you want to continue [Yy/Nn]?
现在,因为我有多个Linux系统可以做到这一点因此我正在寻找ansible来为我做这个工作,所以,我刚刚用ansible adhoc
方式测试了同样的方法如下工作shell
模块......
# ansible all -m shell -a 'echo "y" | /opt/altiris/notification/nsagent/bin/aex-uninstall'
dev-karn | SUCCESS | rc=0 >>
This will remove the Symantec Management Agent for UNIX, Linux and Mac software from your system.
Are you sure you want to continue [Yy/Nn]?
Uninstalling dependant solutions...
Uninstalling dependant solutions finished.
Removing Symantec Management Agent for UNIX, Linux and Mac package from the system...
Removing wrapper scripts and links for applications...
Sending uninstall events to NS
Stopping Symantec Management Agent for UNIX, Linux and Mac: [ OK ]
Remove non packaged files.
Symantec Management Agent for UNIX, Linux and Mac Configuration utility.
Removing aex-* links in /usr/bin
Removing RC init links and scripts
Cleaning up after final package removal.
Removal finished.
有没有更好的方法来做到这一点...... 任何想法将不胜感激。
答案 0 :(得分:2)
您应该使用Ansible expect模块。
答案 1 :(得分:0)
linux shell的yes
实用程序重复输出y
,它满足了程序提示的每个预答案的必要性,以及我作为我正在运行的程序的要求,只需要答案是yes
继续,因此我在下面用ansible shell
模块...
$ ansible all -m shell -a '/bin/yes | /opt/altiris/notification/nsagent/bin/aex-uninstall'
所以,即使echo "y"
也不需要。
Thnx - Karn