send string to input of another process

Kushal Kumaran kushal.kumaran+python at gmail.com
Tue Sep 13 16:01:41 CEST 2011


On 13 Sep 2011 17:53, "Alex Naumov" <alexander_naumov at opensuse.org> wrote:
>
> Hello everybody,
>
> I'm looking for some solution, maybe someone of you can help me.
>
> I call another process via os.system("process") and it waits for some
input. I have to write a comment (for example, like using svn or git), and
after that to close input (for example, like ":wq" using vim).
> How can I give/write this comment and put it in the input for next process
(which start after)?
>
>

Take a look at the subprocess module, especially the communicate method.
Note that you will not be able to script screen-oriented programs like vim
using this, unless it has some mode where you can drive it by piping
commands on stdin.

If you want to provide commit messages, I'm sure your vc system accepts
those on the command line instead.

-- 
regards,
kushal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110913/b47a7ec7/attachment.html>


More information about the Python-list mailing list