Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: If file exists

In a batch file (as opposite to WinSCP script file), use %1 (not %1%) to refer to an argument of the batch file.

And yes, to check for results of a script, use the instructions from
https://winscp.net/eng/docs/faq_script_result
Sjar

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?
martin

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).
Sjar

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