if statement for "Connection refused"

Advertisement

Whykonen
Guest

if statement for "Connection refused"

Hello, i want to sent an error e-mail only when connection is refused. How do i catch this, is there a error level or code to catch it?

If a file fails transferring, i don't want to send an e-mail.

It seems errorcode 1 is wider then what i want.

batch:
:nietwinxp
echo nietwinxp
winscp.com /script=buo-nietwinxp.txt
if errorlevel 1 goto error
goto end

log of connection refused:
. 2011-01-31 14:43:51.468 Looking up host "backuponline.webboy.nl"
. 2011-01-31 14:43:51.473 Connecting to 195.241.102.8 port 22
. 2011-01-31 14:43:53.581 Server unexpectedly closed network connection
* 2011-01-31 14:43:53.585 (ESshFatal) Server verbrak onverwacht de netwerkverbinding.

Reply with quote

Advertisement

whykonen
Guest

anyone??

I want to detect if the IP has changed, because i use a access list. Thats what i'm trying to filter out with an errorlevel, to send mail. But errorlevel 1 seems to wide.

please help!

Reply with quote

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

Re: if statement for "Connection refused"

There's no simple solution. But you can use XML logging. If it contains just empty <session/> tag (like below) and exit code is 1, it is likely that the connection has failed for some reason.

<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="my session" start="2011-02-02T07:17:47.632Z">
</session>

Reply with quote

Advertisement

You can post new topics in this forum