help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using listen to receive commands


From: Corbin Champion
Subject: Re: using listen to receive commands
Date: Mon, 20 Mar 2006 17:55:49 +0000

Are you familiar with perl? I am not familiar with tcl, but I have taken a look at both files you pointed me at, and they seem to make sense to help get me started. Based on looking at the eval function and then converting to perl, I am trying to do a basic test of talking to octave from perl. I have included the code here. The perl script is able to connect to the octave that is listening "listen(2000)". It then prints the !!!x format, is this done correctly?...probably not. Then I see after the disconnect from the socket "accept: no child processes" printed out on the octave terminal that is listening. I know something is wrong only by the fact that the file temp.txt was not created. What should I expect to have printed out on the octave terminal as connections are made and commands are sent?

#!/usr/bin/perl -w
# send.pl
# a simple client using IO:Socket
#----------------

use strict;
use IO::Socket;

my $host = shift || 'localhost';
my $port = shift || 2000;
my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket :$!";

print scalar(localtime);
print $sock "!!!x";
print $sock sprintf("%b",60);
print $sock "fid = fopen('temp.txt', 'w'); fprintf(fid,'this is perl\n');";
print scalar(localtime);

sleep(5);

close $sock;

Thanks for you help!
Corbin




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]