Ask Your Question

prompt input for exec

asked 2015-06-12 15:59:57 -0600

Tawha gravatar image

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 ?

edit retag flag offensive close merge delete


what product are you using? most I've used previously would be able to use a file to set settings rather than go interactive (maybe google your product name and answer file or non-interactive)

sahumphries gravatar imagesahumphries ( 2015-06-13 05:52:44 -0600 )edit

yes that what i was asking for, how can i use a file to prvide the interactive input rather than giving it by ourself from command prompt ? because as you know puppet runs by itself

Tawha gravatar imageTawha ( 2015-06-13 15:54:22 -0600 )edit

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

far4d gravatar imagefar4d ( 2015-06-15 02:30:22 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-12 22:40:37 -0600

GregLarkin gravatar image

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
edit flag offensive delete link more


is there anyway i can tell exec resource to fetch the required input from a file ?

Tawha gravatar imageTawha ( 2015-06-13 15:55:17 -0600 )edit

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.

GregLarkin gravatar imageGregLarkin ( 2015-06-14 00:51:50 -0600 )edit

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

Tawha gravatar imageTawha ( 2015-06-14 05:43:31 -0600 )edit

No, there is not.

GregLarkin gravatar imageGregLarkin ( 2015-06-14 10:39:32 -0600 )edit

answered 2015-06-14 20:52:34 -0600

Don't forget the Unix 'yes' command.

$ yes |(read i; echo $i)


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-06-12 15:59:57 -0600

Seen: 1,208 times

Last updated: Jun 14 '15