0

I have a bash script like this:

#some commands
#.....
read answer
#....
#Other commands

the answer should be yes or no.

I want to run the script and bypass reading answer giving it the value yes. But I can't edit the script's code.

Is there anyway to do that using parameters or some bash tools??

1
  • 3
    Is that read the only input required by the script? In that case a simple echo "yes" | ./script.sh would work. Commented Sep 3, 2013 at 11:45

1 Answer 1

4

Just pipe a 'yes' into the standard input of your script:

echo yes | your_bash_script
Sign up to request clarification or add additional context in comments.

1 Comment

Yes!, that's it. thank you very much. I don't know how I didn't think about that, so close!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.