[erlang-questions] receiving output from a python shell

pablo platt <>
Mon Jan 28 00:20:12 CET 2013


When executing a python file or command it works
but when starting a python shell and interacting with it I'm not getting
any output

1> Port = open_port({spawn, "python -c \"print 1\""}, [binary,
exit_status]).
#Port<0.586>
2> flush().
Shell got {#Port<0.586>,{data,<<"1\n">>}}
Shell got {#Port<0.586>,{exit_status,0}}
ok


On Mon, Jan 28, 2013 at 1:13 AM, Joseph Wayne Norton <
> wrote:

>
> Here is a snippet that invokes a python program and captures the output.
>
> https://github.com/norton/asciiedoc/blob/master/src/asciiedoc_lib.erl#L96
>
> This example isn't interactive but might be of help to you.
>
> regards,
>
> Joe N.
>
> On Jan 28, 2013, at 8:03 AM, pablo platt <> wrote:
>
> erlport looks interesting but I don't need to manipulate the python shell
> response.
> I want to start a python shell (or any other shell), send arbitrary
> commands to it and get the response.
>
> On Mon, Jan 28, 2013 at 12:53 AM, Steve Vinoski <> wrote:
>
>>
>>
>> On Sun, Jan 27, 2013 at 4:56 PM, pablo platt <>wrote:
>>
>>> How can I get the output of a python shell?
>>>
>>> This is what I'm trying to do:
>>> > Port = open_port({spawn, "python"}, [binary, exit_status]).
>>> #Port<0.586>
>>> > port_command(Port, "print 1\n").
>>> true
>>> > flush().
>>> ok
>>>
>>> When calling flush(), I expect to get {Port,{data, <<"1\n">>}}
>>> but I'm not getting any message.
>>>
>>
>> You might want to try ErlPort:
>>
>> http://erlport.org
>>
>> Otherwise, you're just going to have to re-code what ErlPort already
>> gives you.
>>
>> --steve
>>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130128/f790db78/attachment.html>


More information about the erlang-questions mailing list