How to transfer file from one PC to another using PERL?

Hi All

I have two PC connected with each other via LAN cable.
In one of the PC the Perl is installed. What I want to do is transfer the data from one PC to another via Perl.
Is it possible to do this.

---------- Post updated at 11:31 PM ---------- Previous update was at 07:01 AM ----------

I have used Net::FTP but i didn't find the way.

What's your attempt with Net::FTP?

Here it is

use Net::FTP;
use strict;

open (fh, "> abc.txt");

print fh "this is test data\n";
close fh;


my $ftphost='XXXXXX';
my $ftpuser='XXXXXX';
my $ftppass='XXXXXX';
my $outdir= 'C:/';

my $outfile='C:/Users/XXXXXX/Documents/abc.txt';


# FTP the file
            my $ftp = Net::FTP->new($ftphost,Debug => 1) || die "Unable to establish ftp connection to $ftphost";
           $ftp->login($ftpuser, $ftppass) || die "Unable to log into $ftphost as $ftpuser/$ftppass";
            $ftp->ascii || die  "Unable to change the Type to Ascii\n";
           $ftp->put("$outdir", "$outfile") || die "Unable to ftp $outfile to $ftphost.\n";
         $ftp->quit();
        print "The data output file $outfile was ftpd to $ftphost \n";

You have to set the remote working directory and you can't set that with put method. you have to use cwd method.

$ftp->cwd("$outdir") or die "Cannot change working directory ", $ftp->message;
$ftp->put("$outfile") || die "Unable to ftp $outfile to $ftphost.\n";

Cheers,
Ranga:)

Thats correct but what i will write in
my $ftphost my $ftpuser my $ftppass

You can use the remote ipaddress or hostname in $ftphost.
You can get the ipaddress by execute ipconfig in command prompt of remote machine and execute hostname in command prompt of remote machine
As you know the user name and password of the remote machine for $ftpuser and $ftppass.

Cheers,
Ranga:)

I have done that same But i am getting Error

Please share your error description with us. so that we can proceed :slight_smile:

and the error is

Unable to establish ftp connection to 111.110.111.211 at C:\Users\XXXXX\
Documents\test.pl line 19.

It seems to be firewall issue. guys any idea???

Do you actually have an FTP daemon running on that server? If you don't, it of course won't be able to connect to FTP...