Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Executing cora commands from python


french Nov 2, 2012 04:13 AM

I have written a script in python that I intend to help create simple loggernet device entries.

But I have hit a wall, is there any way of feeding commands to cora_cmd.exe with out directly inputting the command into the interpreter.

Such as (from windows command) "C:\Program Files(x86)\Campbellsci\LoggerNet\cora_cmd.exe" -connect localhost;

Or perhaps pass it a file with the commands written inside.


kirving Nov 2, 2012 06:39 AM

You might look at pexpect, "a pure Python module that makes Python a better tool for controlling and automating other programs. Pexpect is similar to the Don Libes `Expect` ...".
I haven't used it, but have used Expect in other forms. Typically, you tell Expect what program to wrap or control, then send commands and wait for responses, which can be handled in various ways.


mjb Nov 4, 2012 08:29 PM

Cora will execute commands piped to it on standard input, for example, you can:

echo connect localhost;lists-stations;exit; | cora_cmd.exe

although, cmd.exe's echo is very limited - but you could likely have your python script execute cora_cmd.exe as a sub process and pass it input via a filehandle to the subprocess's stdin:

http://stackoverflow.com/questions/163542/python-how-do-i-pass-a-string-into-subprocess-popen-using-the-stdin-argument


french Nov 4, 2012 11:39 PM

Thanks guys.

mjb that is the exact answer I was looking for. Cheers.

Log in or register to post/reply in the forum.