简体   繁体   English

单行 bash 脚本调用另一个要求用户名和密码的脚本

[英]One-liner bash script to invoke another script that asks for username and password

I need to run the script on Linux OS given by HPE in OVCs and I need to run this on almost all the nodes in all the federations.我需要在 OVC 中 HPE 提供的 Linux 操作系统上运行该脚本,并且我需要在所有联邦中的几乎所有节点上运行该脚本。

Hence I am writing one more small batch file to run that script which is there in the OVCs.因此,我正在编写另一个小批处理文件来运行 OVC 中的那个脚本。

The original script which is given by HPE and which is in OVC asks for the administrator user name and password. HPE 提供的原始脚本位于 OVC 中,要求输入管理员用户名和密码。 However, I don't know how to supply this username and password to a batch file?但是,我不知道如何将此用户名和密码提供给批处理文件?

I am able to write a batch file and it run it, but not sure how to pass through the username and passwords.我能够编写一个批处理文件并运行它,但不确定如何传递用户名和密码。

To pass-through, some text (including passwords) can be done like this:要传递,一些文本(包括密码)可以这样完成:

Send string to stdin 将字符串发送到标准输入

But I would discourage you from doing this.但我会劝阻你不要这样做。 Could you maybe add sudo entry for your script so you could invoke the sudo (and get root access) for that one script without needing passwords (still safer than pass through passwords in plain text), then when your script will run as root, then whatever you invoke might not need the administrative password anymore.您能否为您的脚本添加sudo条目,以便您可以在不需要密码的情况下为该脚本调用 sudo(并获得 root 访问权限)(仍然比以纯文本方式传递密码更安全),然后当您的脚本以 root 身份运行时,然后无论您调用什么,都可能不再需要管理密码。

When you need to deploy something on many machines there are other tools can be used.当您需要在多台机器上部署某些东西时,可以使用其他工具。 For example ansible can applied the changes on multiple nodes easily.例如 ansible 可以轻松地在多个节点上应用更改。 Only thing needed on the nodes is SSH server.节点上唯一需要的是 SSH 服务器。

https://en.wikipedia.org/wiki/Ansible_(software) https://en.wikipedia.org/wiki/Ansible_(软件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM