Page 1 of 1

network dump to csv

Posted: 26 Nov 2013 11:23
by Saunders
Hey All,

So i made a simple script (that is probably sloppy but it still works somehow) that im trying to get excel to read. The script outputs a mac address, type and netbios identifier per IP given. It is nice and pretty in a text file but excel hates it. Any tips on how to get the output in a text or csv file as IP , csproduct type , Netbios , MAC?

FOR /L %i IN (1,1,254) DO (((((
echo.
)
echo target machine 10.1.100.%i
)
wmic /node :10.1.100.%i csproduct get name | findstr /I "N a m e"
)
NBTSTAT -A 10.1.100.%i | findstr /I "unique"
)
arp -a 10.1.100.%i |findstr /I "dynamic"
)>>C:\SCRIPTdump.txt


Thanks
Art

Re: network dump to csv

Posted: 26 Nov 2013 18:24
by foxidrive
There could be a few problems, one being that WMIC output is sloppy with embedded spaces, nuls and carriage returns.

If you supply the scriptdump.txt file in a dropbox download link then we can take a look at a massaging the text into a csv format.

Re: network dump to csv

Posted: 26 Nov 2013 19:07
by Squashman
Well for starters you would want to put each command into a FOR /F command so that you could capture the output of the command and assign it to a variable. The you could output all the variables as a comma separated string to the CSV file.

But as Foxidrive said, WMIC can be tricky at times.

Re: network dump to csv

Posted: 04 Dec 2013 10:01
by zpimp
im doing something similar but first ping ip to see if its on, and parsing commands output using perl
using wmic i get mac,serial,hdd

i used to love batch but its limits are easily reached

perl is just awesome
reading command output to a variable is as simple as $var=`command`;
too bad perl fork is bad on windows so i cant do it all at once :(