巴什苏期望组合 [英] Bash su expect combo

查看:63
本文介绍了巴什苏期望组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个脚本来帮助我自动进行安装.在此安装过程中,我必须从root切换到另一个用户gpadmin,然后运行安装的最后一站.此时,我致电:

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'

这可行,但是我必须手动通过EULA和其他参数.我使用了here文档来完成所有工作,但是由于某种原因,这将阻止创建安全证书并破坏安装.为了避免这种情况,我想尝试在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?

推荐答案

在修补之后,我发现期望确实有效.我误会了我所期望的确切是什么.

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

这可以规避EULA,并且不需要整个SU过程.

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

这篇关于巴什苏期望组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆