From dbc8b62bc7b74495cee4f2ab9bf29c04ab78c165 Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sat, 5 Jan 2008 05:15:06 +0000 Subject: move SERVER_STDIN and SERVER_STDOUT inside the class hash svn path=/branches/new-fu/; revision=326 --- client/Scire.pm | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/client/Scire.pm b/client/Scire.pm index 5530ff3..dca8da4 100644 --- a/client/Scire.pm +++ b/client/Scire.pm @@ -37,8 +37,6 @@ package Scire::Communicator; use IPC::Open2; -my ($SERVER_STDIN, $SERVER_STDOUT); - sub new { my $proto = shift; my $class = ref($proto) || $proto; @@ -46,8 +44,8 @@ sub new { port => 22, user => scire, server_script => "/usr/bin/scireserver.pl", -# SERVER_STDOUT => undef, -# SERVER_STDIN => undef, + SERVER_STDOUT => undef, + SERVER_STDIN => undef, @_ }; bless ($self, $class); @@ -69,12 +67,13 @@ sub send_command { $tosend .= " \"${arg}\""; } } -# debug("Sending: ${tosend}"); - print SERVER_STDIN "${tosend}\n"; + $tosend .= "\n"; + + my ($tmpin, $tmpout) = ($self->{SERVER_STDIN}, $self->{SERVER_STDOUT}); + print $tmpin $tosend; #FIXME WE NEED A TIMEOUT HERE OF SOME SORT!! #if the server doesn't give you a newline this just hangs! - my $response = ; -# debug("Got response: ${response}"); + my $response = <$tmpout>; return $self->parse_response($response); } @@ -94,7 +93,7 @@ sub create_connection { # doesn't fail in the main process. When it fails, it outputs an error # to STDERR: # open2: exec of ../server/scireserver.pl failed at ./scireclient.pl line 116 - $self->{connection_pid} = open2(*SERVER_STDOUT, *SERVER_STDIN, $self->{connection_command}); + $self->{connection_pid} = open2($self->{SERVER_STDOUT}, $self->{SERVER_STDIN}, $self->{connection_command}); } sub build_connection_command { @@ -113,8 +112,6 @@ sub build_connection_command { # Overwrite $connection_command in the case of a dev environment for now $connection_command = "../server/scireserver.pl"; } - -# return $connection_command; $self->{connection_command} = $connection_command; } -- cgit v1.2.3-65-gdbad