pythonbashshell

run python script and specifying answers to the prompt questions


I have a python script which I can Only run, not modify.

While execution, via terminal one has to type "Y" or "N" as an answer to 1 question.

Is there a way to run/execute a python script with specifying the answer on it in advance?

I am aware that whenever this is possible one should rather make a respective option in a script to avoid this issues.


Solution

  • Just use printf built-in alone in bash

    printf "yes\n" | <yourscript>
    

    As requested in the comments,

    printf "yes\nCatDog\nno\n"