Bootstrap FreeKB - Perl (Scripting) - Transfer a file
Perl (Scripting) - Transfer a file

Updated:   |  Perl (Scripting) articles

This script will transfer myFile.txt from server1 to server2.

#!/usr/bin/perl
use Core;
use Utility;
use Options;

# Initialize the logger
$logger = init_logger();

my $user = "root";

print "Enter target server name: ";
my $target_server = <STDIN>;
chomp $target_server;

print "What file do you want to transfer: ";
my $local_file = <STDIN>;
chomp $local_file;

print "Where should the file be stored on the target server: ";
my $remote_file = <STDIN>;
chomp $remote_file;

sub transferFile
{
    ($stdout, $stderr, $exit) = create_shell($host, $user, $pass);
    $logger->info("Getting ready to transfer your file");
    copyFileRemote($target_server,$user,$local_file,$remote_file,"false","true");
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 25d9e9 in the box below so that we can be sure you are a human.