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

how i can write bash file to copy files from unix box to windows "remotly" box by sftp command ???

share|improve this question
up vote 2 down vote accepted

For automated scripts, try scp or rsync.

from "man sftp":

-b batchfile Batch mode reads a series of commands from an input batchfile instead of stdin. Since it lacks user interaction it should be used in conjunction with non-interactive authentication. A batchfile of â-â may be used to indicate standard input. sftp will abort if any of the following commands fail: get, put, rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd, df, and lmkdir. Termination on error can be suppressed on a command by command basis by prefixing the command with a â-â character (for example, -rm /tmp/blah*).

also look at

share|improve this answer
ok i know but the other side "windows" put condition "use sftp" maybe it is don't support scp – Mohammad AL-Rawabdeh Nov 29 '10 at 8:11

The cURL php extension for windows supports sftp. You should try to find a php script that you can place on the windows server and add to scheduled jobs. Wouldn't be too hard to create your own either. I'm sure python and .net have support for sftp as well.

Or, you could install cyqwin (nasty hack) on windows and write a bash script.

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.