3

I have a script StartProcess.sh that accepts two options in stdin - 3 and a filename test.xml.

If I run the below script, it executes correctly, and waits again for the input. I want someway to pass 3 and test.xml n times to StartProcess.sh. How do I achieve this.

./StartProcess.sh << STDIN -o other --options 
3
test.xml
STDIN

1 Answer 1

1

You can run a loop to pass the arguments as many times in a loop and run a script over a pipe-line. That way, the script is just launched once and the arguments gets sent over stdin any number of times of your choice

count=3
for (( iter = 0; iter < 3; iter++ )); do
    echo "3" "test.xml"
done | StartProcess.sh

But I'm not fully sure if you wanted to pass the literal string test.xml as an argument or the content of the file.

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.