/usr/share/doc/libnet-sftp-foreign-perl/examples/sftp_tail.pl is in libnet-sftp-foreign-perl 1.81+dfsg-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/perl
use strict;
use warnings;
use Net::SFTP::Foreign;
use Fcntl qw(SEEK_END);
@ARGV == 1
or usage();
my ($host, $file) = $ARGV[0] =~ /([^:]+):(.+)/ or usage();
my $sftp = Net::SFTP::Foreign->new($host);
$sftp->error and die "Unable to connect to remote host: ".$sftp->error."\n";
my $fh = $sftp->open($file)
or die "Unable to open file $file: ".$sftp->error."\n";
# goto end of file
seek($fh, 0, SEEK_END);
my $sleep = 1;
while (1) {
while (<$fh>) {
print;
$sleep = 1;
}
print "### sleeping $sleep\n";
sleep $sleep;
$sleep++ unless $sleep > 5;
}
sub usage {
warn <<EOW;
Usage:
$0 [user@]host:/path/to/file
EOW
exit 0;
}
|