1

I would like to build a script like this:

#!/bin/bash          
/path/to/my/program/myProgram
MyCommand1    < — This is NOT a bash command
MyCommand2    < — Neither is it

Those are commands acceptable only by some sort of interactive session of my program. Any ideas how do I do that?

0

1 Answer 1

2
echo -e "MyCommand1\nMyCommand2"| /path/to/my/program/myProgram

or

/path/to/my/program/myProgram << EOF
MyCommand1
MyCommand2
EOF

When you want to have some delay in your input, try this:

(sleep 2; echo "MyCommand1"; sleep 1; echo "MyCommand2") | /path/to/my/program/myProgram
Sign up to request clarification or add additional context in comments.

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.