prompt input for exec

i am automating my hardening via puppet. While configuring auditing, there is a command whihc propts for yes or no
But when i execute this command through puppet, when i manually trigger the agebt, it keeps on running , because it is not getting that yesy stding .
How can i provide such stding for exec ?

If your interactive program accepts a file as an "answer" to the question, you are already done. If the program insists on getting the answer from the keyboard, then use expect. this is the primary use case of expect. does "echo yes | program" work? is your answer always "yes"? more details pls

2 Answers

There is no way to supply interactive input to a command invoked with an exec resource in your Puppet code. Assuming the answer to the question is either always "yes" or always "no", I suggest one of the following solutions:

Supply the answer via a command-line argument, if supported

Supply the answer by redirecting stdin to the command, if supported

In the worst case, you can use a tool like expect to interact with the command if the previous options are not available

Comments

Sure, as long as it's some non-interactive process for retrieving the input. Whatever you do, it has to be specified as a command just like you would run in a shell. The exec resource itself doesn't have any special features for retrieving input.

I know that the basic function of exc is to execute command on Agent, that is what everyone knows.
What i was asking specifically was that is there any way to give the prompted input in exec command ?
I am really looking forward for your respsonse