0

Consider shell scripts which ask user's input to proceed or not[yY/nN] and another script calls all these scripts.
I don't want to give Yy input manually.
Note: User input is not an argument to a script and it occurs anytime during script execution.
Consider 3 shell scripts viz: a.sh, b.sh, c.sh.
On execution, scripts prompt:

"You want to Proceed[Y/y/N/n]?"

Now, Wrapper.sh calls a.sh, b.sh, c.sh and also provides Y/y or N/n input as and when those scripts prompts.
I can not pass an argument as a.sh "Y"
[ps: a.sh b.sh c.sh are not executable and non-editable]
Can not install any third party plugins on RHEL, So need to use only default plugins/commands.

2 Answers 2

2

You can try expect tool which is used to feed input automatically to an interactive program. Try to begin with something like this:

#!/usr/bin/expect

set timeout 10

spawn "PATH_TO/a.sh"
expect "You want to Proceed" 
send "y\r"

interact
Sign up to request clarification or add additional context in comments.

1 Comment

I'm sorry but I am not allowed to install any tool on machine.
0

I haven't used this myself, but take a look at 'expect'. This exactly what it's there for. Good luck!

Comments

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.