I'm trying to use the findstr
in the Testing_Results1
to find the string Conexão falhou.
. But's not working because the ã
.
I tried to replace Conexão
for ConexÆo
but not worked. Also tried to skip the ã
by this way ^ã
but also not working.
:Testing_Results1
findstr /I /C:"Conexão falhou." WinSCP.log >nul && (
echo Sem conexÆo com a internet.
echo Verifique o problema e tente novamente.
pause
goto End
) || (
goto Testing_Results2
)
:Testing_Results2
findstr /I /C:"Conexão perdida" WinSCP.log >nul && (
echo ConexÆo com o servidor perdida. Tente novamente.
pause
goto end
) || (
goto Success
)
:Success
echo Arquivo(s) Exportado(s) com sucesso.
echo/ &echo/ &echo/
pause
goto End
:Error
echo Erro desconhecido ocorrido.
pause
goto End
:End
del /f /s /q %temp%\ftpsend.dat >nul 2>nul
del /f /s /q WinSCP.log >nul 2>nul
exit
Maybe this question can be considered duplicated of these:
But there i didn't found solution for my problem.
Any idea?
Edit 1:
Follow a piece of my WinSCP.log
. 2019-05-24 14:36:21.725 --------------------------------------------------------------------------
. 2019-05-24 14:36:21.725 Session name: xxxx@ftp.xxxx.com.br (Ad-Hoc site)
. 2019-05-24 14:36:21.725 Host name: ftp.xxxx.com.br (Port: 21)
. 2019-05-24 14:36:21.725 User name: xxxxx(Password: Yes, Key file: No, Passphrase: No)
. 2019-05-24 14:36:21.725 Transfer Protocol: FTP
. 2019-05-24 14:36:21.725 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec
. 2019-05-24 14:36:21.725 Disable Nagle: No
. 2019-05-24 14:36:21.725 Proxy: None
. 2019-05-24 14:36:21.725 Send buffer: 262144
. 2019-05-24 14:36:21.725 UTF: Auto
. 2019-05-24 14:36:21.725 FTPS: None [Client certificate: No]
. 2019-05-24 14:36:21.725 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto
. 2019-05-24 14:36:21.725 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2019-05-24 14:36:21.725 Cache directory changes: Yes, Permanent: Yes
. 2019-05-24 14:36:21.725 Recycle bin: Delete to: No, Overwritten to: No, Bin path:
. 2019-05-24 14:36:21.725 Timezone offset: 0h 0m
. 2019-05-24 14:36:21.725 --------------------------------------------------------------------------
. 2019-05-24 14:36:21.725 Conectando a ftp.xxxxx.com.br...
. 2019-05-24 14:36:21.725 Conexão falhou.
Edit 2:
Follow an image of my cmd
using this code:
@echo on
findstr /I /C:"Conexão falhou" WinSCP.log
echo %errorlevel%
pause
The exact behavior you see depends a bit on what code page your text file is using. Assuming your file uses code page 1252 - Latin (Western European), then ã
is 0xE3 (decimal 227).
The reason your FINDSTR fails is explained at What are the undocumented features and limitations of the Windows FINDSTR command? under the section Character limits for command line parameters - Extended ASCII transformation. There it explains how FINDSTR transforms (corrupts) many non-ASCII command line characters into an ASCII value.
If you read the referenced section, you will see that character 227 is transformed into 112, which corresponds to the letter p
. So your FINDSTR command is looking for the wrong string.
The only way to use FINDSTR to search for your string is to put the search string in a text file and use the /g:file
option. FINDSTR does not corrupt characters when using the /G
option.
If the contents of "search.txt" is a single line Conexão falhou
, then the following command will match the correct lines:
findstr /I /L /G:search.txt WinSCP.log
That being said, the way the string is displayed may be incorrect, depending on your active code page. My machine defaults to code page 437, so ã
is displayed as π
on my machine. Either way, the character code is 0xE3. If you pipe the results of the FINDSTR to a file, you should see the correct result.
If you really want to put the search string on the command line, then you can explicitly specify a regular expression search even though you use /C
by adding the /R
option. You can then use .
to match any character at the offending position.
findstr /I /R /C:"Conex.o falhou" WinSCP.log
Another option is to use the FIND command instead:
find /I "Conexão falhou" <"WinSCP.log"
Though on my machine I need the following due to active code page 437
find /I "Conexπo falhou" <"WinSCP.log