DanoPlu
DanoPlu

Reputation: 299

How to execute custom command in bash script

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?

Upvotes: 1

Views: 2608

Answers (1)

Walter A
Walter A

Reputation: 19982

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

Upvotes: 2

Related Questions