Stdin


#1

Hello All. Can anybody clarify that is CHEF able to work with STDIN.
Recipe should take inputs that will allow to set various variables .
I tried to do it with ruby_block but it says “error: No such file or
directory - -c”
Here is ruby block :

ruby_block “puts_some_text” do
block do
print("Enter your variable: ")
STDOUT.flush
a_string = gets
puts a_string
end
action :create
end


#2

Without more context it’s hard to debug what is causing your error. In
general, asking for input this way is a very bad idea (as Chef is
usually intended to be run stand-alone, without a user at the
console.)

That said, there is no reason it won’t work. You probably want to do
STDIN.gets, just for safety.

Best,
Adam

On Fri, Sep 23, 2011 at 5:23 AM, hiltov@altoros.com wrote:

Hello All. Can anybody clarify that is CHEF able to work with STDIN.
Recipe should take inputs that will allow to set various variables .
I tried to do it with ruby_block but it says “error: No such file or
directory - -c”
Here is ruby block :

ruby_block “puts_some_text” do
block do
print("Enter your variable: ")
STDOUT.flush
a_string = gets
puts a_string
end
action :create
end


Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E: adam@opscode.com