I am trying to write code for automating /etc/init.d/oracleasm configure command where as it needs 4 inputs to proceed.
Default user to own the driver interface [grid]: grid
Default group to own the driver interface [y]: oinstall
Start Oracle ASM library driver on boot (y/n) [y]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Generally what is the best way to write code for achieving this. Please suggest me.
It would be better if you had a command you could run non-interactively, but you can run an interactive command using
expect
. Based in your example it would be:It is important
/etc/init.d/oracleasm configure
to be an idempotent command, this means that you can run it once, twice or one hundred times and its behavior and the result system will be the same. If this is not the case, you need some guards to the command (only_if
ornot_if
) to run only the command when needed: