Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file on CentOS machine that needs to be copied to Windows NT server.

I use \ to connect to the server from my windows desktop. I can copy the files using the GUI,

but I want to write a shell script on my centOS server that will periodically copy files to windows box.

share|improve this question
why not make a script on windows that runs periodically and copies the file? – quamis Jun 8 '11 at 12:22
why not run rsync as a CRON job on the NIX box? – user265029 Jan 14 '15 at 22:43
up vote 4 down vote accepted

Mount the Windows NT server on your CentOS machine:

mkdir /mnt/windows
mount -t cifs -o user=your-windows-username // /mnt/windows

Requires smbfs/cifs. From here on, it's just normal cp or rsync or whatever you want to do.

share|improve this answer
This is the correct answer. But how do I set the ownership of the mounted partition to "companyuser". I guess it is not possible as it is part of another server. – shantanuo Jun 9 '11 at 6:45

There is another option not mentioned here. You can use the PuTTY suite of tools, specifically pscp to copy a file from the CentOS box to the Windows box. Get pscp (google) and use the command prompt in the directory where pscp resides:

pscp .

This will copy the file to the current directory.

share|improve this answer
....or use smbclient, (or ftp, webdav, scp....if there's a suitable server on the MSWindows box) – symcbean Jan 14 '15 at 23:29

You could map a share with samba from the windows server on your centos box. Then it is a normal cp command you have to do.

You can find the needed information in smbclient howto.

share|improve this answer
# You must have smbfs support compiled into your kernel to use these (smbmount) utilities! # How do I enable this? # thanks for your quick answer. – shantanuo Jun 8 '11 at 12:13
What version of centos is it? All the versions I know have it already compiled into. – Raffael Luthiger Jun 8 '11 at 14:55
# cat /etc/redhat-release # Red Hat Enterprise Linux Server release 5.5 (Tikanga) – shantanuo Jun 9 '11 at 6:01

As it's an NT server I'm going to assume that this is in a closed environment where security isn't an overwhelming issue (if I'm wrong then why are you still using NT?).

If you don't have smbfs support on your CentOS machine, as suggested by your comment to Raffael's answer, you could enable the NT machine's FTP server and use scripted FTP commands to perform the file transfer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.