0

We have a tool written in C# where we write vb.net scripts. Now, I need to integrate python in it so that we can run python scripts in same tool. All, the tool does is send string command and capture the string response.

My question: do I need to write interpreter for this?How can I talk to python engine. Is there any other way I can implement this? Links to get it going would be helpful. Just started with python today!

Thanks!

user2801184
  • 329
  • 7
  • 27
  • Just invoke the python interpreter with your desired .py file and pipe the output wherever you want. If you don't want to use a file, the interpreter also has a `-c` command line parameter which accepts python statements to execute. – Asad Saeeduddin Mar 07 '14 at 23:02
  • Hi Asad, I am still trying to find info about invoking python interpreter. Will get back to you on this. How about performance if python interpreter is invoked from the existing tool? Links and info is appreciated if any? Thanks! – user2801184 Mar 08 '14 at 00:09
  • The python interpreter is just the executable that runs python scripts. If you've installed it on a box and it's configured correctly, it's probably already on the path, in which case you can just open up a command line and type "python" or "py" to start an interactive python session. The interpreter also accepts command line arguments, such as a path to a python script which it can execute, or raw python statements for it to execute directly. – Asad Saeeduddin Mar 08 '14 at 00:26
  • I am not sure what to tell you about "performance". What are you comparing performance against/between? Different python interpreters? – Asad Saeeduddin Mar 08 '14 at 00:28
  • Is it possible that I can send commands to from tool__>python interpreter-->product. And capture response from interpreter and write to excel sheet? How about performance compared to sending commands directly to box from the tool – user2801184 Mar 08 '14 at 00:55

1 Answers1

0

Look into IronPython to fill your scripting needs. IronPython will provide you all of the features of Python but from within the .Net framework. Here is a previous question concerning embedding IronPython in C#

Michael Foord has an post on embeddeding IronPython into C#. There are several methods to achieve this goal. The simplest being to create a hosting engine from within C# and embed a string of Python code that will be executed.

Community
  • 1
  • 1
santhon88
  • 62
  • 2
  • 6