#!/usr/bin/perl -w
######################################################
# #
# #
# Script to send files to server #
# Author: Jurison Murati #
# #
######################################################
use strict;
use Net::SCP::Expect;
use File::Copy;
use IO::Compress::Gzip qw(gzip $GzipError);
my $host = "192.168.0.1";
my $user = "user";
my $pwd = "password";
my $RemoteDir = </nodes>;
my $file;
my $displaydate= `date +'%Y%m%d%H%M%S'`;
print "Filloi dergimi date $displaydate\n";
my $scp = Net::SCP::Expect->new(host=>$host,user=>$user,password=>$pwd,recursive=>1);
my $dir = '/arch';
opendir(DIR, $dir) or die $!;
while (my $file = readdir(DIR)) {
next if ($file =~ m/^\./);
$scp->scp("$dir/$file","$RemoteDir") or die $scp->{errstr};
print "file $dir/$file moved on date $displaydate\n";
}
exit 0;