Problem in executing the batch file in winscp

和自甴很熟 提交于 2019-12-22 01:37:51

问题


I am new to Winscp and I am having a problem in executing a batch file.

The scenario is something like this:

I have a batch file A, two folders (up B and down folders C), some text files in up folder D, a text file E (different from the files in D) and a ppk file F. All these things are in one folder only.

The batch file A is having a script (script is shown below) which contains text. If that text contents are true (means if that text (text contents are related to E i.e. if the text file E is executed) is executed) then only the files in up folder B moves to down folder C.

And the script in batch file A is:

C:\somefolder\WinSCP3.exe /console /script=E.txt /log=session.log
if errorlevel 1 goto error
xcopy C:\somefolder\up\*.*  C:\somefolder\down\  /y
del  C:\somefolder\up\*.*   /Q
:error
echo Upload failed, keeping local files

And the content in text file E is:

option batch abort
option confirm off
open @test.com 
change remote directory
cd \somedirectory
option transfer binary
put C:\somefolder\up\*.*
close
exit

I don't know why the files from up folder is not moving to down folder.

Please let me know where exactly the problem is and how to resolve that problem....


回答1:


Thanks to Andriy M. His comments cleared my confusion and gave the right answer.

Here are the right syntax.

C:\somefolder\WinSCP3.exe /console /script=E.txt /log=session.log

xcopy C:\somefolder\up\*.*  C:\somefolder\down\  /y
del  C:\somefolder\up\*.*   /Q

if errorlevel 1 goto error

:error
echo Upload failed, keeping local files

The content in text file E.txt is:

option batch abort
option confirm off
open @test.com 
change remote directory
cd \somedirectory
option transfer binary
put C:\somefolder\up\*.*
close
exit



回答2:


Dunno if anyone still read this thread or not.. But what I know is "put" command upload the files from Local Directory to Remote Directory. TS wanted to "download the files from Remote Directory to Local Directory" so I think the right command is "get".

Cheers, Shen



来源:https://stackoverflow.com/questions/5382964/problem-in-executing-the-batch-file-in-winscp

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