How to copy from a windows network to a linux machine

Posted on

QUESTION :

I need to create a batch that regularly copies a file file.txt from a windows remote machine (located at 1.2.3.4Client$) to a linux machine located at 7.8.9.10.
The batch should run on the linux machine.
What is the simplest way to do it?

ANSWER :

My guess is that the easiest is to:

Get Windows file sharing working.

Make sure you have the smbclient program on your Linux box. This is usually in a package called samba-client or similar.

Make a script, something like smbclient //1.2.3.4/Share -c 'get /file /dest/dir1'

Depending on what your permissions are, you may want to add an authentication file, name and password. so it would be smbclient -a smb_auth.txt //1.2.3.4/Share -c 'get /file /dest/dir1'

Schedule this in cron.

Note: This doesn’t match your requirements exactly

If you can go from Windows to linux instead of the reverse, you can use WinSCP and it’s ‘synchronize folders’ feature:

  1. Connect to the linux box using WinSCP
  2. Select: Commands –> Keep Remote Directory up to Date...

    File Menu showing Commands --> Keep Remote Directory up to Date…”></p>
</li>
<li>
<p>Set the parameters as needed</p>
<p><img src=

This will keep the remote directory up to date automatically for you. You can also use their scripting functionality to keep things updated.

Leave a Reply

Your email address will not be published.