• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anyone REALLY Good in Batch?

hevnsnt

Lifer
I am trying to do a simple line that will resolve an hostname into an IP.. Here is where I am at.


FOR /F "tokens=3 delims= " %%A IN ('PING -a %1 -n 1 ^| FIND "Reply"') DO ECHO.%%A

Now, this will return the IP as such 1.2.3.4: I need to be able to remove the ":" from the variable.. Anyone know how to do this?

 
Originally posted by: hevnsnt
I figured it out using nslookup instead of ping.. thanks 🙂

Nslookup is the way to do it.

Ping is a PITA for this b/c it gives you too much extra info to strip out. About the easiest way to do it would be to take your result IP address and run it through a FOR /F using . as the delim, which effectively strips it out.

Edit: Misread.
If you had added : as a delim, you would strip it out. Thought you wanted to get the dots out.

FOR /F "tokens=3 delims=: " %%A IN ('PING -a %1 -n 1 ^| FIND "Reply"') DO ECHO.%%A
 
Back
Top