how to input a respond to prompt of a command by python?
Question: I ma running a Python code utilizing from prompt commands. It sometimes
conflicts with the existing files and says

    
    
    File 'outputs/g/Charlotte_s_Web_2006_-_Trailer.avi' already exists. Overwrite ? [y/N]
    

where the file name is changing.

Is it possible to capture that question and input `N` as an answer constantly
on Python?


Answer: If you're running on some UNIX variant, you can do

    
    
    yes N | <program>
    

which feeds a never-ending stream of "N"s to the program.

If you want to control a console-driven program from Python, consider using
`pexpect`. This library enables very simple interaction:

    
    
    import pexpect
    pexpect.spawn("<cmd>")
    while 1:
        child.expect(r'\[y/N\]')
        child.sendline('N')
    

