Hello I have written a perl script that takes port scans that i had saved in a text file and out put them to Microsoft Excel. Now my boss wants it to output in in excel in csv format such as
Server, port, protocol, state, service, 69.25.194.2, 25, tcp, open, smtp
I would like to have all the IP's in column A, ports in columns B and so forth. I guess I could use matching regular expressions but I'm new to perl and having trouble doing this Can you guys help me.
Here is my Code this outputs the text file to Excel can I modify this format the excel file in the format that I want it in.
$input = `Cat /cygdrive/c/Windows/System32/test11.txt | grep -v 'SYN Stealth'`;
chomp input;
$output =" /cygdrive/c/Users/bpaul/Desktop/194.csv ";
if (! -e "$output")
{
`touch $output`;
}
open (OUTPUTFILE, ">$output") || die "Can't Open file $output";
print OUTPUTFILE "$input\n";
close (OUTPUTFILE);
Here is a piece of my file
Nmap scan report for 69.25.194.2 Host is up (0.072s latency). Not shown: 9992 filtered ports PORT STATE SERVICE 25/tcp open smtp 80/tcp open http 82/tcp open xfer 443/tcp open https 4443/tcp closed pharos 5666/tcp closed nrpe 8080/tcp closed http-proxy 9443/tcp closed tungsten-https
touch
an non-existing file before opening it for overwriting; it will be created automatically. Andgrep
doesn't need anything piped to it; it knows how to read from files (and you should almost certainly be doing the grepping from within perl itself). - Wooble