3

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

I use \10.10.10.10 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.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
shantanuo
  • 3,579
  • 8
  • 49
  • 66

4 Answers4

5

Mount the Windows NT server on your CentOS machine:

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

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

cvaldemar
  • 1,106
  • 1
  • 10
  • 12
  • 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 09 '11 at 06:45
3

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 root@ip.of.centos.box:/path/to/file .

This will copy the file to the current directory.

Sean C.
  • 954
  • 5
  • 7
1

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.

Raffael Luthiger
  • 2,001
  • 2
  • 17
  • 26
1

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.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109