Batch file when using WinSCP and command prompt

不想你离开。 提交于 2019-12-23 03:35:17

问题


I am currently writing a script that calls WinSCP, connects an SFTP session, transfers a group of files from a local server to a remote server, closes the connection, then moves the local file to an archive. An alternate acceptable solution would be to copy the file to archive and then delete it from the source directory.

The problem I am having is that I can get WinSCP to open, connect and transfer the files, but after that the commands are ignored and I am unable to automate the connection close, file move or copy and the deletion and closing of command prompt. What is the best way to do this?

My FTP.bat file that connects the session and calls the script -

"C:\Program Files\WinSCP\WinSCP.exe" /console /command "lcd d:\bofa_ftp\out" /script=script.txt savedsession@winscpname.com

My script file that puts the file and closes the connection -

option batch abort
option confirm off
option exclude script.txt
put *.txt
close

When I add any commands to either the bat or the script they are ignored.


回答1:


Commands after close are definitely not ignored. Your problem might be that you are trying to put Windows commands to WinSCP script. Note that there are no commands in WinSCP to move local files.




回答2:


Instead of trying using Winscp3, try with plink.exe.

Plink is the best option to transfer files from winscp3 to your local.By using scp command we can transfer file from winscp to local as well as one folder in to another folder in winscp.

scp username@atechguideserver1.com:/data/tmp/samplscp.txt username@atechguideserver2.com:/data/tmp/dir/tech

Please refer to: http://99students.com/move-files-in-unix/



来源:https://stackoverflow.com/questions/9692691/batch-file-when-using-winscp-and-command-prompt

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