timestamps in der ausgabe. mtu 1400.
This commit is contained in:
parent
4c98f7f23f
commit
590ac40933
8
c.rb
8
c.rb
|
@ -3,6 +3,10 @@
|
||||||
libexec = File.expand_path File.dirname( __FILE__)
|
libexec = File.expand_path File.dirname( __FILE__)
|
||||||
machine, source, destination = ARGV[0...3]
|
machine, source, destination = ARGV[0...3]
|
||||||
|
|
||||||
|
def ts
|
||||||
|
Time.now.strftime '%Y-%m-%d %H:%M:%S'
|
||||||
|
end
|
||||||
|
|
||||||
class IO
|
class IO
|
||||||
def readall
|
def readall
|
||||||
buf = ''
|
buf = ''
|
||||||
|
@ -36,13 +40,13 @@ if Process.fork
|
||||||
tor.last.close
|
tor.last.close
|
||||||
$stdout.reopen tos.last
|
$stdout.reopen tos.last
|
||||||
tos.first.close
|
tos.first.close
|
||||||
$stderr.puts( {:proc => 'c', :machine => machine, :source => source}.inspect)
|
$stderr.puts( {:ts => ts, :proc => 'c', :machine => machine, :source => source}.inspect)
|
||||||
exec 'ssh', machine, 'perl', '-e', File.readall( File.join( libexec, 's.pl')).shdump, source.shdump
|
exec 'ssh', machine, 'perl', '-e', File.readall( File.join( libexec, 's.pl')).shdump, source.shdump
|
||||||
else
|
else
|
||||||
$stdin.reopen tos.first
|
$stdin.reopen tos.first
|
||||||
tos.last.close
|
tos.last.close
|
||||||
$stdout.reopen tor.last
|
$stdout.reopen tor.last
|
||||||
tor.first.close
|
tor.first.close
|
||||||
$stderr.puts( {:proc => 'c', :exec => 'reciever', :destination => destination}.inspect)
|
$stderr.puts( {:ts => ts, :proc => 'c', :exec => 'reciever', :destination => destination}.inspect)
|
||||||
exec 'perl', File.join( libexec, 'r.pl'), destination
|
exec 'perl', File.join( libexec, 'r.pl'), destination
|
||||||
end
|
end
|
||||||
|
|
17
r.pl
17
r.pl
|
@ -2,11 +2,16 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use POSIX qw(strftime);
|
||||||
$|++;
|
$|++;
|
||||||
|
|
||||||
|
sub ts {
|
||||||
|
strftime '%Y-%m-%d %H:%M:%S', localtime;
|
||||||
|
}
|
||||||
|
|
||||||
$SIG{CLD} = sub {
|
$SIG{CLD} = sub {
|
||||||
wait;
|
wait;
|
||||||
printf STDERR "{proc: \"r\", action: \"exit\", code: $?, error: \"child_died\"}\n";
|
printf STDERR "{ts: \"".ts."\", proc: \"r\", action: \"exit\", code: $?, error: \"child_died\"}\n";
|
||||||
exit $?;
|
exit $?;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,13 +23,13 @@ sub readcmd {
|
||||||
$data;
|
$data;
|
||||||
}
|
}
|
||||||
|
|
||||||
chdir $ARGV[0] or die( "{proc: \"r\", error: \"cannot_chdir\", exception: \"$!\"}\n");
|
chdir $ARGV[0] or die( "{ts: \"".ts."\", proc: \"r\", error: \"cannot_chdir\", exception: \"$!\"}\n");
|
||||||
while( my$data = readcmd) {
|
while( my$data = readcmd) {
|
||||||
(my$cmd, my$length) = unpack( 'nN', $data);
|
(my$cmd, my$length) = unpack( 'nN', $data);
|
||||||
print STDERR "{cmd: $cmd, length: $length}\n";
|
print STDERR "{ts: \"".ts."\", cmd: $cmd, length: $length}\n";
|
||||||
read STDIN, $data, $length;
|
read STDIN, $data, $length;
|
||||||
if( 1 == $cmd) {
|
if( 1 == $cmd) {
|
||||||
open( F, '>>', $data) or die( "{proc: \"r\", error: \"unable_to_open_file\", message: \"Can't open file <$data>.\"}\n");
|
open( F, '>>', $data) or die( "{ts: \"".ts."\", proc: \"r\", error: \"unable_to_open_file\", message: \"Can't open file <$data>.\"}\n");
|
||||||
my@stat = stat F;
|
my@stat = stat F;
|
||||||
print pack( 'N', $stat[7]);
|
print pack( 'N', $stat[7]);
|
||||||
}
|
}
|
||||||
|
@ -32,8 +37,8 @@ while( my$data = readcmd) {
|
||||||
print F $data;
|
print F $data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die( "{proc: \"r\", error: \"unknown_command\", command: $cmd}\n");
|
die( "{ts: \"".ts."\", proc: \"r\", error: \"unknown_command\", command: $cmd}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print STDERR "{proc: \"r\", exit: 0}\n";
|
print STDERR "{ts: \"".ts."\", proc: \"r\", exit: 0}\n";
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
22
s.pl
22
s.pl
|
@ -2,30 +2,34 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
#use warnings; # Old perl
|
#use warnings; # Old perl
|
||||||
|
use POSIX qw(strftime);
|
||||||
$|++;
|
$|++;
|
||||||
|
|
||||||
|
sub ts {
|
||||||
|
strftime '%Y-%m-%d %H:%M:%S', localtime;
|
||||||
|
}
|
||||||
|
|
||||||
my$dir = shift @ARGV;
|
my$dir = shift @ARGV;
|
||||||
$dir =~ /^(\/.*)\/([^\/]+)$/ or die( "{proc: \"s\", error: \"invalid_path_expression\", message: \"Path-Expression is invalid.\"}\n");
|
$dir =~ /^(\/.*)\/([^\/]+)$/ or die( "{ts: \"".ts."\", proc: \"s\", error: \"invalid_path_expression\", message: \"Path-Expression is invalid.\"}\n");
|
||||||
($dir, my$fexpr) = ($1, $2);
|
($dir, my$fexpr) = ($1, $2);
|
||||||
|
|
||||||
chdir( $dir) or die( "{proc: \"s\", error: \"change_directory\", value: \"$dir\", message: \"$!\"}\n");
|
chdir( $dir) or die( "{ts: \"".ts."\", proc: \"s\", error: \"change_directory\", value: \"$dir\", message: \"$!\"}\n");
|
||||||
opendir( DH, '.') || die "{proc: \"s\", error: \"dir_not_found\", message: \"Directory not found.\"}\n";
|
opendir( DH, '.') || die "{ts: \"".ts."\", proc: \"s\", error: \"dir_not_found\", message: \"Directory not found.\"}\n";
|
||||||
while( my$filename = readdir( DH)) {
|
while( my$filename = readdir( DH)) {
|
||||||
$filename =~ /$fexpr/ or next;
|
$filename =~ /$fexpr/ or next;
|
||||||
-f $filename or next;
|
-f $filename or next;
|
||||||
print pack( 'nNA*', 1, length($filename), $filename);
|
print pack( 'nNA*', 1, length($filename), $filename);
|
||||||
print STDERR "{proc: \"s\", action: \"open\", file: \"$filename\"}\n";
|
print STDERR "{ts: \"".ts."\", proc: \"s\", action: \"open\", file: \"$filename\"}\n";
|
||||||
open F, $filename;
|
open F, $filename;
|
||||||
my( $length, $r);
|
read STDIN, my$length, 4; # Was wenn < 4 ?
|
||||||
read STDIN, $length, 4; # Was wenn < 4 ?
|
|
||||||
$length = unpack 'N', $length;
|
$length = unpack 'N', $length;
|
||||||
seek F, $length, 0;
|
seek F, $length, 0;
|
||||||
while( read( F, $r, 2040)) {
|
while( read( F, my$r, 1400)) {
|
||||||
print pack( 'nNA*', 2, length($r), $r);
|
print pack( 'nNA*', 2, length($r), $r);
|
||||||
}
|
}
|
||||||
print STDERR "{proc: \"s\", action: \"close\", file: \"$filename\"}\n";
|
print STDERR "{ts: \"".ts."\", proc: \"s\", action: \"close\", file: \"$filename\"}\n";
|
||||||
close F;
|
close F;
|
||||||
}
|
}
|
||||||
closedir DH;
|
closedir DH;
|
||||||
print STDERR "{proc: \"s\", exit: 0}\n";
|
print STDERR "{ts: \"".ts."\", proc: \"s\", exit: 0}\n";
|
||||||
exit( 0);
|
exit( 0);
|
||||||
|
|
Loading…
Reference in a new issue