Prvni zavorka za 'do' ve FOR cyklu se nesparuje spravne s posledni, ale
nespravne s tou predposledni (escapovanou).
:read_ip
for /f "tokens=1,2 delims=," %%A in ('
mysql -s -u root --password^=sa -h server -D db -e "SELECT pid,ip FROM person_ip
WHERE pid='%~1'"^; 2^>NUL^| sed --file^=expression.sed
') do (
if "%db_type%"=="2" (
REM == Testing if address is
public or private
echo %%~B| findstr /R
"^[10\.12\.]" >NUL
if not errorlevel 1 (set /a
"ip_type=1") else (
REM ==
testing if address is ipv4 or ipv6
echo
%%~B| findstr ":" >NUL
if not
errorlevel 1 (set /a "ip_type=3") else (set /a "ip_type=2")
)
)
echo INSERT into ip_addr VALUES^(^
'%%~A',^
'%%~B',^
'%ip_status%',^
'%ip_type%',^
'',^
''^)^;>> import.sql
)
GOTO:EOF
--
<http://forum.pspad.com/read.php?1,62303,65852>
PSPad freeware editor http://www.pspad.com