Enter a letter when prompted by another command
I'm trying to automate the 开发者_如何学Goinstallation 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.
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).
Try
echo y | /usr/local/bin/amf install...
精彩评论