<div dir="ltr"><div>Thank you very much, Peter!<br></div>It works!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 23, 2013 at 9:32 AM, Peter Otten <span dir="ltr"><<a href="mailto:__peter__@web.de" target="_blank">__peter__@web.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Alex Naumov wrote:<br>
<br>
> I'm trying to call new process with some parameters. The problem is that<br>
> the last parameter is a "string" that has a lot of spaces and different<br>
> symbols like slash and so on. I can save it in file and use name of this<br>
> file as parameter, but my question is: how to make it without additional<br>
> saving?<br>
><br>
> import subprocess as sp<br>
><br>
> rc = sp.Popen(["prog", "--options", "<", msg], stdin=sp.PIPE,<br>
> stdout=sp.PIPE)<br>
> stdout = rc.communicate()[0]<br>
> print stdout<br>
<br>
</div><div class="im">> p.s.<br>
> type(msg) => <type 'str'><br>
<br>
</div>The < operator is a shell feature, not an argument, and msg is intended to<br>
be send to prog's stdin. The communicate() method accepts a parameter for<br>
that. So:<br>
<br>
rc = sp.Popen(["prog", "--options"], stdin=sp.PIPE, stdout=sp.PIPE)<br>
stdout = rc.communicate(msg)[0]<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>