views:

16

answers:

2

Hi all,

I'm trying to automate the installation and deployement of an application.

To do it, i have a shell script with the following instructions:

/usr/local/bin/amf install -u $1 -p $2 $localTarget

where $1, $2 and $localTarget are options for the command named 'amf'.

The problem is that the 'amf' command make severall instructions and ask the user to enter a letter during those instructions (to confirm the installation). At the moment, i can't bypass or modify the behaviour of the 'amf' command, so my question is:

How can i catch this behaviour and/or automatically enter a letter in my script.

This behaviour currently make my script not working, because the 'amf instal...' instruction is followed by another command to start my application. But as the install failed, the application can't start.

Thanks in advance for your help.

Best regards.

Kij.

A: 

Try

echo y | /usr/local/bin/amf install...
Aaron Digulla
A: 

Aaron's solution will only enter a single "y" character. If your amf command expects multiple, identical, inputs, then you may like to try:

yes | /usr/local/bin/amf install -u $1 -p $2 $localTarget

yes outputs y repeatedly forever (or, in the case of the pipeline, until amf exits). It takes an optional parameter, so

yes OchAye | /usr/local/bin/amf install -u $1 -p $2 $localTarget

will repeately enter "OchAye" into amf (just in case it's Scottish).

Chris
kij