Ask Your Question
0

prompt input for exec

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

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

Comments

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 -0500 )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 -0500 )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 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

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

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

Comments

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 -0500 )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 -0500 )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 -0500 )edit

No, there is not.

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

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

Don't forget the Unix 'yes' command.

$ yes |(read i; echo $i)
y

:)

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

Stats

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

Seen: 912 times

Last updated: Jun 14 '15