Context
I check several servers with nmap and I send the result by email.
I concatenate a variable with new result for each server and each ports with this code (I removed loops):
SET text=
SET text=!text!+"<h1>server %%i:</h1>
SET text=!text!+"Port %%a : %%b<br/>"
SET text=!text!+"<br/>"
And I send one email with text variable.
Email rendering:
server 2:
+Port 8443 : https-alt
+
+
server 3:
+Port 2103 : zephyr-clt
+Port 2105 : eklogin
+Port 2107 : msmq-mgmt
+Port 49155 : unknown
+
+
I try whithout + but it doesn’t work:
SET text=
SET text=!text! "<h1>server %%i:</h1>
SET text=!text! "Port %%a : %%b<br/>"
SET text=!text! "<br/>"
I try unsuccessfully several alternatives.
Question
How to concatenate my text variable without ugly +?
Answer which works
SET "text="
SET "text=!text! ^<h1^>server %%i^</h1^>^<br/^>"
SET "text=!text! Port %%a %%b^<br/^>"
SET "text=!text! ^<br/^>"
%blat% -server %server% -port %port% -f %from% -to %to% -html -s "Opened ports" -body "!text!"
Output:
It doesnt work because you have special character in your strings (quotes, <, >, \, etc.).
You have to use the quote ” and the remove the quotes with the following code: