Bash su expect combo

Deadly 提交于 2021-01-29 20:39:08

问题


I currently have a script to help me automate an install. During this install I have to switch from root to another user, gpadmin, and run the final leg of the install. At this point I call:

su - gpadmin -c 'echo source /usr/local/greenplum-perfmon-web-4.1.2.0-build-2/gpperfmon_path.sh > .bashrc2;

source ~/.bashrc2;

gpperfmon --setup'

This works but I have to manually go through the EULA and other parameters. I had used a here document to go through and finish everything but for some reason this would prevent the creation of a security certificate and break the install. To circumvent this I wanted to attempted to use expects after the gpperfmon --setup command. Will these expects be called correctly even though they are being passed to a different user using the ticks?


回答1:


After tinkering around I found that the expect does work. I was mistaken in what I though expect was exactly.

spawn "/gp/install/gppermon.bin"
expect "EULA:"
send \003

That works to circumvent the EULA, and the entire SU process is not required.



来源:https://stackoverflow.com/questions/9022445/bash-su-expect-combo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!