If file exists

Advertisement

Sjar
Guest

If file exists

Hi
I use a batch file to call winscp.
What I'm trying to do is send a parameter from the bat file to winscp and check that the file has been correctly uploaded.
So here's what my bat file looks like,beside the point is that the bat file is called from SQL server.

REM Batfile
winscp.com /console /script=Web_Test1.txt /parameter %1% /log=c:\WinScp.log
IF %ERRORLEVEL% neq 0 goto error

ECHO Success> c:\sucess_%1%.txt
EXIT /b 0

: ERROR
ECHO Error> c:\error_%1%.txt
EXIT /b 1

_______________________________________________________________
This is how the scipt file looks like Web_Test1.txt

option batch abortion
option confirm off
open ftp: // username: password@remotesite.com
option transfer binary
put c:\%1%
state %1%
exit

#Would above be all that is needed or should I add below:
IF% ERRORLEVEL% neq 0 goto error
exit

error
ECHO Error> c: \ error_% 1% .txt
exit
#Comment End

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: If file exists

Sorry, I do not understand what is your question.

Btw, this is definitely a wrong syntax: /parameter %1%
(though I cannot tell how you should fix it, as I do not understand, what you want).

Reply with quote

Sjar
Guest

Re: If file exists

martin wrote:

Sorry, I do not understand what is your question.

Btw, this is definitely a wrong syntax: /parameter %1%
(though I cannot tell how you should fix it, as I do not understand, what you want).


I realize my description was not easy to understand, sorry for that.

I’m using winscp called from a bat file (SendToFTP.bat)
I’m running a batch file called SendToFTP.bat with /xxx.yyy.html.
/xxx.yyy.html is an parameter and is handled by the variable %1% inside the bat file.

The bat file should then start winscp and send the specific file to be transferred to FTP with winscp as specified in the %1% variable. (in this case xxx.yyy.html)

I need to check that the file I send up to the FTP server has actually ended up on the FTP server.
Because the entire flow should be done automatically, I need to get back some type of error if xxx.yyy.html did not end up on the FTP server.

So what are they was I can verify that my file actually ended up on the FTP?

Reply with quote

Advertisement

You can post new topics in this forum