How to transfer a file using Perl

Home > Search > How-to
  by

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");
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments