Simulate key press in a recipe

I know if you have to do that, it means something is wrong ! but for some
legacy application I really need to run a shell script wait a few seconds
and then
type something and hit “Enter”

is it possible in chef?

2015-03-06 2:06 GMT+03:00 Medya medya.gh@gmail.com:

I know if you have to do that, it means something is wrong ! but for some
legacy application I really need to run a shell script wait a few seconds
and then
type something and hit "Enter"

is it possible in chef?

use expect for this, or write in ruby needed logic inside recipe.

--
Vasiliy Tolstov,
e-mail: v.tolstov@selfip.ru
jabber: vase@selfip.ru

is there a resource or a cookbook ? is it possible that u give me this
example ?

first run the shell script

./myscript.sh

#wait 5 seconds, type this
501

hit enter

On Thu, Mar 5, 2015 at 5:08 PM, Vasiliy Tolstov v.tolstov@selfip.ru wrote:

2015-03-06 2:06 GMT+03:00 Medya medya.gh@gmail.com:

I know if you have to do that, it means something is wrong ! but for some
legacy application I really need to run a shell script wait a few seconds
and then
type something and hit "Enter"

is it possible in chef?

use expect for this, or write in ruby needed logic inside recipe.

--
Vasiliy Tolstov,
e-mail: v.tolstov@selfip.ru
jabber: vase@selfip.ru

You can use the ruby PTY module, but it’s very tricky to do this in a reliable way. For example, these tests start chef-shell, wait for it to finish initializing and then exit. IO handling and timeout stuff is the vast majority of the code. https://github.com/chef/chef/blob/master/spec/functional/shell_spec.rb

--
Daniel DeLeo

On Thursday, March 5, 2015 at 3:08 PM, Vasiliy Tolstov wrote:

2015-03-06 2:06 GMT+03:00 Medya <medya.gh@gmail.com (mailto:medya.gh@gmail.com)>:

I know if you have to do that, it means something is wrong ! but for some
legacy application I really need to run a shell script wait a few seconds
and then
type something and hit "Enter"

is it possible in chef?

use expect for this, or write in ruby needed logic inside recipe.

--
Vasiliy Tolstov,
e-mail: v.tolstov@selfip.ru (mailto:v.tolstov@selfip.ru)
jabber: vase@selfip.ru (mailto:vase@selfip.ru)

you can use stdlib based module PTY from lwrp/hwrps:

chef's mixlib-shellout library too support STDIN arguments:

On Thu, Mar 5, 2015 at 3:08 PM, Vasiliy Tolstov v.tolstov@selfip.ru wrote:

2015-03-06 2:06 GMT+03:00 Medya medya.gh@gmail.com:

I know if you have to do that, it means something is wrong ! but for some
legacy application I really need to run a shell script wait a few seconds
and then
type something and hit "Enter"

is it possible in chef?

use expect for this, or write in ruby needed logic inside recipe.

--
Vasiliy Tolstov,
e-mail: v.tolstov@selfip.ru
jabber: vase@selfip.ru