Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to copy a file from unix machine to windows machine, from commandline.

share|improve this question

migrated from stackoverflow.com Sep 27 '11 at 21:33

This question came from our site for professional and enthusiast programmers.

3 Answers 3

Assuming that, the Windows box have a shared folder. You can use smbclient command. Which provide a FTP-like command line interface over the SMB protocol.

This post provide a ready to use example, which looks a perfect answer.

If you need to copy files to or from a windows server from a unix server, you can use an utility from the Samba software suite called smbclient.

Here is an example to copy a file to a Windows server:

 smbclient //WIN_SERVER/SHARE -l WIN_SERVER_IP -A AUTHFILE -c "put
 TRANSFER_FILE_LOCAL TRANSFER_FILE_REMOTE"

where:

WIN_SERVER = the name of your Windows server

SHARE = the name of your Windows share

WIN_SERVER_IP = the IP address of your Windows server

AUTHFILE = full path to your authentication file name. The file contents should include:

username = mywinuser
password = mywinpass
domain = MYDOMAIN

TRANSFER_FILE_LOCAL = full path to Unix file to transfer

TRANSFER_FILE_REMOTE = new file name on Windows server

For more help or options using smbclient, type "smbclient -h"

share|improve this answer
    
Top tip. I used smbclient //winhost01/myshare -W mydomain -U myuser -c "get path\to\_readme.txt _readme.txt" –  wmorrison365 May 12 at 13:31

If your windows machine is on the same network, you can share your unix filesystem with smb and mount it on the windows machine, then use "cp" to transfer the file.

You can find information about smb for ubuntu here https://help.ubuntu.com/10.04/serverguide/C/samba-fileserver.html

share|improve this answer
    
What if the script is running on the Unix side? –  recursion.ninja Jan 7 at 20:48

You can use PSFTP to download/upload files to / from Unix server from your Windows machine.

You may see this guide.

share|improve this answer

Your Answer

 
discard

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