diff options
author | Andrew Gaffney <agaffney@gentoo.org> | 2007-12-23 08:08:30 +0000 |
---|---|---|
committer | Andrew Gaffney <agaffney@gentoo.org> | 2007-12-23 08:08:30 +0000 |
commit | 6c82a76b912c7a15ab58b339e7dfb511687846fa (patch) | |
tree | 769e2b609713328f0f96a85b7b363ade7cd8f126 | |
download | scire-6c82a76b912c7a15ab58b339e7dfb511687846fa.tar.gz scire-6c82a76b912c7a15ab58b339e7dfb511687846fa.tar.bz2 scire-6c82a76b912c7a15ab58b339e7dfb511687846fa.zip |
initial perl-based client and server with shiny IPC
svn path=/branches/new-fu/; revision=252
-rwxr-xr-x | client/scireclient.pl | 23 | ||||
-rwxr-xr-x | server/scireserver.pl | 20 |
2 files changed, 43 insertions, 0 deletions
diff --git a/client/scireclient.pl b/client/scireclient.pl new file mode 100755 index 0000000..abf5f3f --- /dev/null +++ b/client/scireclient.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use IPC::Open2; + +my $jobdir = "/tmp/scirejobs"; +my $servercmd = "../server/scireserver.pl"; + +if(! -d $jobdir) { + print "WARNING! ${jobdir} does not exist...creating\n"; + mkdir $jobdir, 0660; +} + +my $pid = open2(*server_stdout, *server_stdin, $servercmd); + +for(('PING', 'FOO', 'QUIT')) { + print "Sending: $_\n"; + print server_stdin "$_\n"; + my $response = <server_stdout>; + print "Got: ${response}"; +} diff --git a/server/scireserver.pl b/server/scireserver.pl new file mode 100755 index 0000000..e328118 --- /dev/null +++ b/server/scireserver.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +$| = 1; +my $jobdir = "/tmp/scirejobs"; + +while(<>) { + my $line = $_; + chomp $line; + if($line =~ /^PING$/) { + print "PONG\n"; + } elsif($line =~ /^QUIT$/) { + print "Exiting!\n"; + exit; + } else { + print "Unknown command\n"; + } +} |