简体   繁体   中英

Shell script auto provide input for command

I am building an auto build script for generating applications. Before I ran every command manually. The build script is almost finished, but there is a problem. Some commands require input, but I don't know how to provide input to the commands without prompting the user. For example:

keytool -genkey -v -keystore Keystore/$name.keystore -alias $lowername -keyalg RSA -keysize 2048 -validity 10000

This asks for the current password which is always the same, but I need to enter this every time.

Is there a way I can provide the answers to the questions I get when running the command without showing this to the user?

You can use the program expect (part of a TCL extension library) to achieve this. It is pretty trivial to use.

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