Erlang ports and Perl

Bob Shafer bobsh@REDACTED
Wed Feb 23 18:04:31 CET 2000

The "ok" is probably stuck in a buffer, and you need to flush it. There's
at least one Perlism for that... I don't have a perl manual handy (and I
use Perl only rarely, so don't remember), but I do have some code that
needed to do that, and it uses "autoflush" and also "$|" might have
something to do with it.

On Wed, 23 Feb 2000, Sean Hinde wrote:

> Hi all,
> I'm having a little difficulty with using a perl script as a port program:
> #!/usr/local/bin/perl
> while(1) {
> $cmd = <STDIN>;
> print STDERR "Received OK";
> print "ok";
> print STDERR "Sent";
> }
> My erlang port program:
> Port = open_port({spawn, "perlscript"}, [stream]),
> Port ! {self(), {command, "hello"}},
> receive
>   Data ->
> 	Data
>   after 10000
> 	timedout
> end
> The result of this is that perl receives the hello message and prints
> "Received OK" and "Sent" on stderr, but my erlang process never receives
> "ok". Tracing confirms that the hello message is sent to the port but
> nothing is received. Using an equivalent C program as the port program with
> the same erlang code works fine.
> Anyone any idea?
> Sean

More information about the erlang-questions mailing list