【发布时间】:2011-07-24 19:17:46
【问题描述】:
我编写了一个 perl 脚本来输出一个包含我扫描到 Microsoft excel 中的 IP 地址和端口的文本文件。现在数据在 excel 中,我的老板希望我以 csv 格式组织文件,例如
Server, port, protocol, random, random, random
ns1, 25, tcp, stuff, stuff, stuff
有谁能帮帮我吗?
代码:
#!/usr/bin/perl
$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);
这是我的一份文件
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
到目前为止,我的代码获取了我的 txt 文件并将其输出到 excel 现在我需要像这样格式化数据:
期望的输出:
Server, port, protocol, random, random, random
ns1, 25, tcp, stuff, stuff, stuff
【问题讨论】: