I've got a script output that's run on dozens of systems and outputs
into a huge csv file. I'm new
at perl and would use Text:CSV but it doesn't understand the blob of
text in ""'s.
Right now I just need to break up the file into a directory for linux,
directory for solaris and put
the blob output in quotes for that hostname into a file in that dir.
I'm not sure how to properly read the blob from beginning to end and
key it off the hostname. Any
ideas?
------------
unixsys52,Solaris8,UltraSPARC-II 296Mhz,1024,"********
Creating a report on all Elan SG products installed on this system
-----------------***********************-----------------
License Key = R8PE-PDIY-NEGG-D34H-6PPP-3PPP-
K3OX
Product Name = Elan Dynatek Help Desk 4.0
Serial Number = 93692
Features :=
********",
(repeat over and over for each new system)
----------------Script-----------------
#!/usr/bin/perl
use File::Path;
my $file = 'licenseout.csv';
my $licfile = "license.txt";
open (F, $file) || die ("Could not open $file!");
while (<F>)
{
if (/UltraSPARC/) {
($hostname,$osver,$proc,$ram,$elanlic) = split ',',
$_;
mkpath "/tmp/elic-solaris/$hostname";
chdir "/tmp/elic-solaris/$hostname";
if (/,"*.."/) {
open (LC, ">>$licfile");
print LC "$_";
}
}
}
if (/Intel/) {
($hostname,$os,$osver,$proc,$ram,$elanlic) = split
',', $_;
mkpath "/tmp/elic-linux/$hostname";
chdir "/tmp/elic-linux/$hostname";
if (/,"*.."/) {
open (LC, ">>$licfile");
print LC "$_";
}
}
}
close (F);