简体   繁体   中英

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.

Hence I am writing one more small batch file to run that script which is there in the OVCs.

The original script which is given by HPE and which is in OVC asks for the administrator user name and password. 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.

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. Only thing needed on the nodes is SSH server.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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