Is there any way to automate the process of copying the files between windows and unix without doing it manually, using tools such as winscp.

I need to copy files from unix to windows such by executing some commands in windows. I goolged it and found these tools that can do this.

winscp console.

EDIT : Can I get something using pscp because I just found out that ftp is not enable in my servers.

Please suggest a way of doing it and I need to run whatever script/command in windows only for copying the unix files.

EDIT 2 : Getting this error in winscp console for sftp :

winscp> get abc.sh c:\
abc.sh                    |          0 KiB |    0.0 KiB/s | binary |   0%
Can't create file 'c:\abc.sh'.
System Error.  Code: 2.
The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all:
  • Regarding your edit 2: You may not have permission to create C:\abc.sh on windows. Commented Jan 24, 2013 at 17:10

5 Answers 5


I would use WinSCP script for this Here you have some good piece of documentation on how to do this. Example script :

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# open sftp://user:[email protected] -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Connect
open sftp://[email protected] -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Change remote directory
cd /home/user
# Force binary mode transfer
option transfer binary
# Download file to the local directory d:\
get examplefile.txt d:\
# Disconnect
# Connect as a different user
open [email protected]
# Change the remote directory
cd /home/user2
# Upload the file to current working directory
put d:\examplefile.txt 
# Disconnect
# Exit WinSCP

Then save it to example.txt and use this command :

winscp.exe /console /script=example.txt


You say you want to automate the process but the at the same time you say you want to run some commands. Other answers contain some command but if you want to have automation, checking out unison might be worth a try. It allows not only unidirectional syncing but also provides a way to keep 2 directories in sync on different machines.


There are several solutions... One way impacts how you'll approach it is where it should be initiated from.

From the Unix device, you should be able to mount a Windows file share and handle it like keeping local files synchronized. (Filenames with characters that Windows dislike might complicate it...)

You can also share the drive and mount it using NFS on Windows (It is in Services for Unix on XP, and an optional component in Vista and newer (might need specific editions, some alternatives are also available)). (Samba can also be used for a Windows file share if you do not want to install the NFS client on Windows)

Once that is set up, you can use tools like Unison and Rsync (or cp for simple cases) (if you do it from the Unix side) or SyncToy or similar tools (for the Windows side) as you would for local files.

scp (and the PuTTY-bundled equivalent pscp might be easier to secure, but need SSH keys set up to work automatically). curl also supports SCP and SFTP (mainly for fetching files) and might be useful for several other options as well.


You should consider also rsync. There are many windows ports.



You can use Samba as file sharing.When you setup it, you can automate it via shell script and crontab.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .