X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fclient.pl;h=cff140b2eb41dba45ee142f7f08891f3066f2e44;hb=cef696652d16bbeec53aca45234ea0b64f3496d3;hp=2a41c221320fbef8120d2af0598a69f6da5be6be;hpb=78ed3f6025103ec1c47c90725e37b417647d83c8;p=spider.git diff --git a/perl/client.pl b/perl/client.pl index 2a41c221..cff140b2 100755 --- a/perl/client.pl +++ b/perl/client.pl @@ -39,6 +39,7 @@ BEGIN { use Msg; use DXVars; +use Carp; $mode = 2; # 1 - \n = \r as EOL, 2 - \n = \n, 0 - transparent $call = ""; # the callsign being used @@ -58,6 +59,8 @@ sub cease if (defined $conn && $sendz) { $conn->send_now("Z$call|bye...\n"); } + STDOUT->flush; + sleep(2); exit(0); } @@ -99,7 +102,7 @@ sub rec_socket my $snl = $mynl; my $newsavenl = ""; $snl = "" if $mode == 0; - if ($mode && $line =~ />$/) { + if ($mode == 2 && $line =~ />$/) { $newsavenl = $snl; $snl = ' '; } @@ -147,7 +150,11 @@ sub rec_stdin if ($mode) { $buf =~ s/\r/\n/og if $mode == 1; $dangle = !($buf =~ /\n$/); - @lines = split /\n/, $buf; + if ($buf eq "\n") { + @lines = (" "); + } else { + @lines = split /\n/, $buf; + } if ($dangle) { # pull off any dangly bits $buf = pop @lines; } else { @@ -196,6 +203,20 @@ $SIG{'HUP'} = \&sig_term; $SIG{'CHLD'} = \&sig_chld; $conn = Msg->connect("$clusteraddr", $clusterport, \&rec_socket); +if (! $conn) { + if (-r "$data/offline") { + open IN, "$data/offline" or die; + while () { + s/\n/\r/og if $mode == 1; + print; + } + close IN; + } else { + print "Sorry, the cluster $mycall is currently off-line", $mynl; + } + cease(0); +} + $conn->send_now("A$call|$connsort"); Msg->set_event_handler(\*STDIN, "read" => \&rec_stdin);