Siddharthan
Siddharthan

Reputation: 141

Command for syncing a file from local computer to a remote server in Java - WinSCP

I'm trying to automate a file synchronisation from a local computer to a remote host in java using WinSCP. Can someone help me suggest what would be the command?

          //---Javacode
          Runtime.getRunTime().exe(cmd /...../);

Upvotes: 0

Views: 780

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202292

WinSCP command-line to synchronize file is like:

winscp.com /command ^
    "option batch abort" ^
    "open sftp://[email protected]" ^
    "synchronize d:\www\ ./www/" ^
    "exit"

See the guide to WinSCP scripting.

Upvotes: 0

chubbsondubs
chubbsondubs

Reputation: 38751

Don't exec(). Use either the ant scp task which will do the same thing as WinSCP, or directly integrate JSCH:

http://www.jcraft.com/jsch/

Much simpler.

Upvotes: 2

Related Questions