init
This commit is contained in:
commit
46cd565e34
14
c.rb
Executable file
14
c.rb
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
tor = IO.pipe
|
||||
tos = IO.pipe
|
||||
|
||||
fork do
|
||||
$stdin.reopen tor.first
|
||||
$stdout.reopen tos.last
|
||||
exec 'ssh', ARGV[0], 'perl', 'r.pl', ARGV[1]
|
||||
end
|
||||
|
||||
$stdin.reopen tos.first
|
||||
$stdout.reopen tor.last
|
||||
exec 'perl', 's.pl', ARGV[2]
|
18
r.pl
Executable file
18
r.pl
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
while( read STDIN, my $data, 6) {
|
||||
my( $cmd, $length) = unpack 'nN', $data;
|
||||
read STDIN, my $data, $length;
|
||||
if( 1 == $cmd) {
|
||||
print STDERR "{action: \"open_file\", file: \"$data\"}";
|
||||
open( F, '>>', $data) or print STDERR ("{error: \"unable_to_open_file\", message: \"Can't open file <$data>.\"}");
|
||||
my( $dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
||||
$atime,$mtime,$ctime,$blksize,$blocks) = stat F;
|
||||
print pack( 'N', $size);
|
||||
}
|
||||
elsif( 2 == $cmd) {
|
||||
print F, $data;
|
||||
}
|
||||
else
|
||||
exit(1);
|
||||
}
|
17
s.pl
Executable file
17
s.pl
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
my $dir = shift @ARGS;
|
||||
$dir =~ /^(\/.*)\/[^/]*$/ or die( '{error: "invalid_path_expression", message: "Path-Expression is invalid."}');
|
||||
$dir, my $fexpr = $1, $2;
|
||||
$fexpr = /$fexpr/;
|
||||
|
||||
opendir( my $dh, $dir) || die '{error: "dir_not_found", message: "Directory not found."}';
|
||||
while( $filename = readdir( $dh)) {
|
||||
print pack( 'nN/(A*)', 1, $filename);
|
||||
open F, $filename;
|
||||
read STDIN, my $length, 4; # Was wenn < 4 ?
|
||||
seek F, $length, SEEK_SET;
|
||||
print pack( 'nN/(A*)', 2, $r) while read( F, $r, 2048);
|
||||
close F;
|
||||
}
|
||||
closedir $dh;
|
Loading…
Reference in a new issue