<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">It's an escape character issue.<div><br></div><div>Since you are pasting source code in your source code, you need to double escape.  Probably as follows:</div><div><br></div><div>PythonEngine.RunSimpleString("execfile('c:\\\\temp\\\\a.py')");</div><div><br></div><div>the c# parser turns that into:  execfile('c:<a href="smb://temp//a.py'">\\temp\\a.py'</a>)</div><div><br></div><div>And then python runs those escape characters and gets:  c:\temp\a.py</div><div><br></div><div>If you don't double escape, C# sends: execfile('c:\temp\a.py')</div><div><br></div><div>And therefore the escape characters \t and \a are executed, resulting in that weird value you got.</div><div><br></div><div><br><div><div>On Apr 4, 2013, at 5:45 PM, Seungweon Park <<a href="mailto:swpark71@gmail.com">swpark71@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div style="">I retested with same code as you have and added online to execute a.py. It looks it running but not the last line</div><div style=""><div><br></div><div>        po = PythonEngine.RunString("execfile('c:<a href="smb://temp//a.py'">\\temp\\a.py'</a>)");<br>
</div><div><br></div></div><div style=""><br></div><div style=""><span><image.png></span><br></div><div style=""><br></div><div style=""><br></div><div style=""><br></div><div style="">So I changed to</div><div style="">
<br></div><div style="">     PythonEngine.RunSimpleString("execfile('c:<a href="smb://temp//a.py'">\\temp\\a.py'</a>)");<br></div><div style=""><br></div><div style="">then, I got </div><div style=""><br></div><div style=""><span><image.png></span><br>
</div><div style=""><br></div><div style=""><div><div>Hello World!</div><div><module 'ntpath' from 'C:\Python27\Lib\ntpath.pyc'></div><div>my\path</div><div>other\path</div><div>5</div><div>Traceback (most recent call last):</div>
<div>  File "<string>", line 1, in <module></div><div>IOError: [Errno 2] No such file or directory: 'c:\temp\x07.py'</div></div><div><br></div><div style="">I don't know why it converted to 'c:\temp\x07.py' from 'c:\temp\a.py', and got the error. Any idea?</div>
<div style=""><br></div></div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 4, 2013 at 2:25 PM, Seungweon Park <span dir="ltr"><<a href="mailto:swpark71@gmail.com" target="_blank">swpark71@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">As you see the screenshot, I ran same application like you, but it doesn't have any output which a.py's supposed to print 'aa' in the screen after "Hello World!".<div>
<br><div><br></div>
</div><div><span><image.png></span><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 4, 2013 at 1:51 PM, <a href="mailto:brad@fie.us" target="_blank">brad@fie.us</a> <span dir="ltr"><<a href="mailto:brad@fie.us" target="_blank">brad@fie.us</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">What happens when you run a compiled application like mine, that has both c# and python console output, directly from within the windows command line cmd.exe?  Do you see the WriteLine() results from C# but not PythonNet?<div>

<br></div><div>That will tell you if it's an execution environment issue or an actual programming issue.  Which is still in question I think.</div><div><br></div><div>-brad<div><br><div><div><div>
On Apr 4, 2013, at 4:40 PM, Seungweon Park <<a href="mailto:swpark71@gmail.com" target="_blank">swpark71@gmail.com</a>> wrote:</div><br></div><blockquote type="cite"><div><div dir="ltr">Image file is not attached. Here it goes.</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Thu, Apr 4, 2013 at 1:37 PM, Seungweon Park <span dir="ltr"><<a href="mailto:swpark71@gmail.com" target="_blank">swpark71@gmail.com</a>></span> wrote:<br>


</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Hi,<div><br>
</div><div>Actually, my questions are </div><div><br></div><div>            1. How to turn on console window(live) from Windows System while debugging Embedded PythonNet app?</div>

<div>            2. How to capture python script execution output from C# code?</div><div><br></div><div>I've been talking to <a href="mailto:Brad@fie.us" target="_blank">Brad@fie.us</a> about my issue which I can't get the output result of any python command using PythonEngine.RunString() or PythonEngine.RunSimpleString(). </div>



<div>I've been tried to debug simple code with Python.Runtime project, but can't find how to turn on this console window, nor capture the python script execution output.</div><div><br></div><div>What I'm trying to do is that I don't want to modify any python script when running a python script from C# code, so I have below code:</div>



<div><br></div></div><div><div><div><br></div><div><div><span style="white-space:pre-wrap">   </span>using System;</div><div><span style="white-space:pre-wrap">    </span>using System.Collections.Generic;</div>
<div><span style="white-space:pre-wrap">  </span>using System.Linq;</div>

<div><span style="white-space:pre-wrap">  </span>using System.Text;</div><div><span style="white-space:pre-wrap">       </span>using System.Threading.Tasks;</div><div><span style="white-space:pre-wrap">    </span>using Python.Runtime;</div>



<div><span style="white-space:pre-wrap">  </span>using System.Diagnostics;</div><div><br></div><div><span style="white-space:pre-wrap">       </span>namespace npythontest</div><div><span style="white-space:pre-wrap">    </span>{</div>



<div><span style="white-space:pre-wrap">          </span>public class Program</div><div><span style="white-space:pre-wrap">             </span>{</div><div><span style="white-space:pre-wrap">                        </span>static void Main(string[] args)</div>
<div><span style="white-space:pre-wrap">                  </span>{</div><div><span style="white-space:pre-wrap">                                </span>PyObject po;</div><div><br></div><div><span style="white-space:pre-wrap">                            </span>PythonEngine.Initialize();</div>



<div><br></div><div><span style="white-space:pre-wrap">                         </span>IntPtr pythonLock = PythonEngine.AcquireLock();</div><div><span style="white-space:pre-wrap">                          </span>po = PythonEngine.RunString("execfile('c:<a>\\cvs\\brocade.py'</a>)");</div>



<div><span style="white-space:pre-wrap">                          </span>PythonEngine.ReleaseLock(pythonLock);</div><div><br></div><div><span style="white-space:pre-wrap">                           </span>PythonEngine.Shutdown();</div><div><span style="white-space:pre-wrap">                 </span>}</div>



<div><span style="white-space:pre-wrap">          </span>}</div><div><span style="white-space:pre-wrap">        </span>}</div></div><div><br></div><div>and a.py prints out many string output. I want to capture this output  by RunString()/RunSimpleString() method, but it doesn't return any result except 'null'. It seems it isn't for getting output. </div>



<div><br></div><div>Then, while talking to Brad, his screenshot from his Mac OS with Mono displays the execution result output on an window like below, so wonder if windows environment can have same console window.</div>



<div>Previously, Oleksii and Sharon mentioned in the thread <a href="http://mail.python.org/pipermail/pythondotnet/2011-March/001103.html" target="_blank">http://mail.python.org/pipermail/pythondotnet/2011-March/001103.html</a>, but don't know it's already implemented or not. However, I can't find how to have same environment from my window system like Brad's Mac has.</div>



<div><br></div><div>So would you help me how to capture the python script output or have console window for debugging when I'm using embedded PythonNet? </div><div><br></div><div>Thank you,</div>
<div>Spark.</div><div><br></div></div><div><span><Screen Shot 2013-04-01 at 6.22.50 PM.png></span><br></div><div><br></div></div></div>
</blockquote></div><br></div>
<span><mono_screenshot_pythonnet.png></span></blockquote></div><br></div></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</blockquote></div><br></div></body></html>