Daily upload of file automation using batch script and WinSCP

情到浓时终转凉″ 提交于 2021-02-08 10:45:01

问题


So I do have a file that I generate weekly from a server using crontab in Linux side and transfer it to my PC. However, I am having a problem when try to send the file that I generate from a different server on Windows side using task scheduler.


回答1:


Your command-line syntax is wrong.

I'm assuming the \ftpBinverlog_%yyyy%-%mm%-%dd%.txt is the file, you want to download.

  • It won't work, if you just specify it on command-line like you did.
  • Also neither Windows scheduler, nor command-interpreter, nor WinSCP understand syntax like %yyyy%.
  • The path to the remote file does not look good either. *nix systems use forward slashes, not backslashes.

So just keep your /script and /log arguments:

/script=C:\batchrun\Binver\script.tmp /log="C:\BIN VERIFICATION\ftplog"

And make sure the script.tmp looks like:

open sftp://user@example.com
get /ftpBinverlog_%TIMESTAMP#yyyy-mm-dd%.txt C:\target_path\
exit

References:

  • Guide to automating file transfer from SFTP server
  • %TIMESTAMP syntax.



回答2:


Develop a batch file which will download/upload the required file using the SCP command check this for more details.

check this for more details about the scp command parameters.

Make sure that you are able to run the batch with a successful result, then configure it within a scheduled task.

I hope this could help.



来源:https://stackoverflow.com/questions/27241038/daily-upload-of-file-automation-using-batch-script-and-winscp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!