1月 312013
 

こんな感じで実行できる。

[raw title=”bat”]
“C:\Program Files (x86)\WinSCP\winscp.com” /script=example.script /log=example.log
[/raw]

[raw title=”example.script”]
option batch abort
option confirm off
open ftp://username:password@hostname -explicittls -certificate=”…”
get /example/* c:\example\
exit
[/raw]

7月 122012
 

FTPタスクが使用しているcommons-netライブラリが日本語環境のFTPに対応していない事が原因。
Antのドキュメントにも記載されている。

FTP Task

Warning: there have been problems reported concerning the ftp get with the newer attribute. Problems might be due to format of ls -l differing from what is expected by commons-net, for instance due to specificities of language used by the ftp server in the directory listing. If you encounter such a problem, please send an email including a sample directory listing coming from your ftp server (ls -l on the ftp prompt).

ファイル一覧を取得する際、日付が日本語で返されるとうまく解析できない模様。
また、Ant1.5以前はcommons-netではなくNetComponentsを使用するが、こちらでも同様の問題が発生する。

恐らく大抵のFTPクライアントは日本語環境のFTPサーバーに対応していない気がする…

対策
  • 方法1.ftp.exeを使う
    BATを書く要領で使える。多分。

  • 方法2.サーバー環境を変更する
    日付が英語で返されるようにすれば良い。

  • 方法3.commons-netを改造する
    面倒。