network dump to csv

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Saunders
Posts: 1
Joined: 26 Nov 2013 09:44

network dump to csv

#1 Post by Saunders » 26 Nov 2013 11:23

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: network dump to csv

#2 Post by foxidrive » 26 Nov 2013 18:24

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: network dump to csv

#3 Post by Squashman » 26 Nov 2013 19:07

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.

zpimp
Posts: 12
Joined: 14 Jun 2013 12:58

Re: network dump to csv

#4 Post by zpimp » 04 Dec 2013 10:01

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 :(

Post Reply