Reputation: 4289
This is also a bash question. I have a script that when run ./recompile
it asks 3 questions, separately, 1 at a time.
The answers are as follows: 1
, 1
, y
.
So I need jenkins to run my script, but to also answer the questions.
Jenkins has this execute shell box, which I take is basically a bash script entry point.
So I have set it to execute my script, but I don't know how to simulate the answers.
I did something like this
./recompile
1
1
y
and
./recompile && 1 && 1 && y
But it says 1 is not a command....
What bash command am I looking for to pass the parameters that will be asked after the script is ran?
EDIT
When the script is run, it should start off like this.
$ ./recompile
Choose the environment to recompile: 1) Dev 2) Stage 3) Prod ? 1
Use Watch mode?y
Will WATCH after dump completed. Use ctrl+c to exit
You are about to recompile Symfony DEV Environment, please verify the following settings:
------------------------------------------
- DEV
- clear cache
- install assets as symlinks
- watch assets, includes force dumping (use ctrl+c to exit)
Ready to run? y
---------------------------
running
Upvotes: 0
Views: 1350
Reputation: 9075
You need to redirect STDIN into your script
$ echo "a
> b
> c" | sh a.sh
a
b
c
a b c
with this sort of bash script for a.sh
#!/bin/bash
echo "a"
read $a
echo "b"
read $b
echo "c"
read $c
echo "a ${a} b ${b} c ${c}"
Upvotes: 1