简体   繁体   中英

modifying IP address in Window Batch

I have a batch command where a user enters an IP address and then I need to modify the last octet based on the second option the user enters. Is there a way to delimit an IP address based on the period? I have only seen ways to use the standard options.

My apologies, I forgot to include what I've got, I would like to find a way to break %a into four different strings.

echo. Enter IP address of the CSR on the site.
echo. Example: 11.152.34.82
set /p a="IP Address: "
pause
cls
echo. select the technology you are trying to restore
echo. 1: AWS
echo. 2: PCS
echo. 3: LTE 1
echo. 4: LTE 2
set /p w="Enter number: "
if "%w%"=="1" goto AWS 
if "%w%"=="2" goto PCS
if "%w%"=="3" goto LTE1
if "%w%"=="4" goto LTE2
echo. Not found
goto commonexit

此命令根据句点拆分。

for /f "tokens=1,2,3,4 delims=." %%a  in ("192.168.1.1") do echo Split into: %%a %%b %%c %%d

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM