rkshyam has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I need to copy several files from a remote windows system(w2k3/w2k8 32 bit or 64 bit) to local windows system(where perl is running) Each file is in a different location and its size varies from few MBs to GBs. ex:c:\dir1\file1 c:\dir1\file2 c:\dir2\file3 etc username will be Administrator and password is password and system ip is 10.10.2.2 I have looked into the perl modules "telnet" and "file copy" but could not get required info. Is there a way to do that? please help

Replies are listed 'Best First'.
Re: file copy from windows system
by BrowserUk (Patriarch) on Jul 20, 2012 at 12:48 UTC
    copy several files from a remote windows system ... to local windows system (where perl is running)

    If this is a windows to windows copy, you do not need telnet or ftp or rsync or any similar server application. Any of the normal file copy commands -- including copy; xcopy robocopy et al. -- can be used to transfer files from a remote windows system to the local one or vice versa.

    Equally, *any* command or module that can copy files locally, will be able to perform the task.

    Provided you have permissionss to access the remote files; and can see them -- via a net use or Active directory or sharepoint etc -- then a simple:

    copy \\remote_machine\share\files.* .

    is all you need.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Thanks to everyone who has replied to this thread. Hi BrowserUK, I have used the method what you have suggested.It worked for smaller f +iles. But when the file size started increasing, the perl script star +ted hanging. In the below code snippet the shyam.txt and shyam1.txt files are of sm +aller size and it gets copied.But when the zip file is being copied, +the script hangs. The zip file is of size around 40-60MB.In the below example out of 4 f +iles only first 3 files are copied that is shyam.txt,shyam1.txt,Logs2 +011-09-19_2321.zip and the 4th zip file is not copied but script got +completed. Can you suggest if something needs to be corrected? If this works then + I need to try copying large log files of size in GBs. Also I would like to know if any perl packages are required to be inst +alled in order to achieve this. thanks in advance
      my $remote_system_ip = "10.10.2.2"; my $user_name = "Administrator"; my $password = "d*diablo123"; my $source_dir = "C:\\shyam\\dir1"; my $target_file1 = "\\\\$remote_system_ip\\c\$\\shyam_IC\\shyam.txt"; my $target_file2 = "\\\\$remote_system_ip\\c\$\\shyam_IC\\shyam1.txt"; my $target_file3 = "\\\\$remote_system_ip\\c\$\\shyam_IC\\Logs2011-09- +19_2321.zip"; my $target_file4 = "\\\\$remote_system_ip\\c\$\\shyam_IC\\Logs2011-09- +19_215.zip"; `net use \\\\$remote_system_ip\\c\$ $password \/user:$user_name`; `copy \/Y $target_file1 $source_dir`; print("1"); `copy \/Y $target_file2 $source_dir`; print("2"); `copy \/Y $target_file3 $source_dir`; print("3"); `copy \/Y $target_file4 $source_dir`; print("4"); `net use \\\\$remote_system_ip\\c\$ \/delete`;
        Can you suggest if something needs to be corrected?

        Yes. When you are copying binary files, (like .zip files), you should be using the /b option. See copy /? for more information.

        If this works then I need to try copying large log files of size in GBs.

        Replace the copy command with the robocopy command. (Rob[ust]copy) and use the /Z option.

        Type robocopy /? for more information.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Re: file copy from windows system
by marto (Cardinal) on Jul 20, 2012 at 11:24 UTC

    What exactly have you tried? Windows doesn't listen for incoming telnet connections as standard, even if it could, what would you do when you got connected? Try mounting the target directory on the remote system and using File::Copy to copy the file. Super Search for more threads on copying directories/files between Windows systems, e.g. File::Copy on Large-ish Files over Network.

    Update: added example link.

Re: file copy from windows system
by aitap (Curate) on Jul 20, 2012 at 12:33 UTC
    What services are available on that systems? Perhaps using SMB or FTP to copy files across network is more handy.
    Sorry if my advice was wrong.