2

I have a Python script which asks for some arguments when running (using raw_input). I'd like to be able to run this script and feed it with some inputs (basically, I need to alternate between 2 values as long as it needs input).

I know how to feed it with a single value using the yes program but I don't know how to obtain a sequence like a b a b a b

What's the simplest way ?

1 Answer 1

6
yes $'a\nb' | script.py

Uses bash's $'...' syntax for string literals which contain escape sequences. Alternatively:

while true; do echo a; echo b; done | script.py
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.