SET command adds quotation marks

  • Thread starter Thread starter Matt G
  • Start date Start date
M

Matt G

Hi,

When I do this in a batch file on a Windows 2003 server...

SET IPADDRESS=10.1.10.20

FOR /F "TOKENS=1,2,3,4 DELIMS=." %%A IN (%IPADDRESS) DO @(
SET octet1=%%A
SET octet2=%%B
SET octet3=%%C
SET octet4=%%D
)

SET reversezone=%octet3%.%octet2%.%octet1%
SET subnet=%octet1%.%octet2%.%octet3%.0/24

echo ipaddress=%IPADDRESS%
echo reversezone=%reversezone%
echo subnet=%subnet%

I get this:

ipaddress=10.1.10.20
reversezone="10"."1"."10"
subnet="10"."1"."10".0/24

I don't want the quotes around each octet in reversezone and subnet. Anyone
know how to remove them?

Thanks in advance.
 
Hi,

When I do this in a batch file on a Windows 2003 server...

SET IPADDRESS=10.1.10.20

FOR /F "TOKENS=1,2,3,4 DELIMS=." %%A IN (%IPADDRESS) DO @(

Change your line above for this:

FOR /F "TOKENS=1,2,3,4 DELIMS=." %%A IN ("%IPADDRESS%") DO @(
SET octet1=%%A
SET octet2=%%B
SET octet3=%%C
SET octet4=%%D
)

SET reversezone=%octet3%.%octet2%.%octet1%
SET subnet=%octet1%.%octet2%.%octet3%.0/24

echo ipaddress=%IPADDRESS%
echo reversezone=%reversezone%
echo subnet=%subnet%

I get this:

ipaddress=10.1.10.20
reversezone="10"."1"."10"
subnet="10"."1"."10".0/24

I don't want the quotes around each octet in reversezone and subnet. Anyone
know how to remove them?

The quotes are some other issue.
 
foxidrive said:
Change your line above for this:

FOR /F "TOKENS=1,2,3,4 DELIMS=." %%A IN ("%IPADDRESS%") DO @(


The quotes are some other issue.

Since the script as pasted into the OP's post contained enough errors that
it did not run at all, the script as it was when it added the spurious
double quotes was obviously different from the one shown. I suspect if he
were to share the script *exactly* as it was when it produced that output,
someone would be able to spot the problem.

/Al
 
Back
Top