'Cant get this IPCONFIG command to display between <p></p> HTML tags

I am having trouble getting this simple code to display the ip address in between <p>/</p> HTML tags.

The code below works, outputting to a text file is ok.

if /i %opt%==1 ipconfig |findstr "IPv4">>"..\LOGS\%NAME%\%serial% %MAC%".txt

The code below is where I would like to embed the CMD code but it just ignores the code or prints in plain text depending on how I modify it; would it need escape characters?

^<td width="38%%" class="table-border-left"^>^<p^>IP Address^</p^>^</td^>

and output to a HTML file:

  >> "..\LOGS\NAME%\%serial% %MAC%".html

Any suggestions?



Solution 1:[1]

To create valid HTML I'd suggest you use a tool like , instead of fiddling with Batch (and lots of escape characters).

ipconfig | xidel -se "(<td width='38%' class='table-border-left'><p>{extract($raw,'IPv4.+: (.+)',1)}</p></td>)"

Alternatively, instead of piping ipconfig to xidel, you can use system() to call ipconfig from within the query. For proper indentation you can use --output-node-indent.

xidel -se "(<td width='38%' class='table-border-left'><p>{extract(system('ipconfig'),'IPv4.+: (.+)',1)}</p></td>)" --output-node-format=html --output-node-indent

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1