Hi,
I try to create a perl script which execute a command and to receive the information (output) from a the command into variables of perl and to store them in a database.
Works fine! Except when there is a space in the output, like name:”VSS Data” this generate a problem in storing the information into the database.
Is there a way to tell Perl that the first 20 charaters of the ouput belongs to the first variable ($sscreate1) and the the next 20 by $sscreate2 etc.
This is the script I created:
#!C:/perl/bin/perl.exe
use Win32::ODBC;
$db = new Win32::ODBC("TestDB");
open (MM, 'mminfo -s Server –r "sscreate(20),sscomp(20),volume(20),level,ssid,totalsize,group,client,name(64),nfiles, metric, type" -t "2 week ago" |') || die "Cannot get mminfo report\n"; @bsinfo = <MM>;
foreach (@bsinfo) { ($sscreate1, $sscreate2, $sscomp1, $sscomp2, $volume, $level, $ssid, $totalsize, $group, $client, $name, $nfiles, $metric, $type) = split;
if ($sscreate1 eq "sscreate1") { next; }
$db->Sql("INSERT INTO NW_SAVESETS (sscreate1, sscomp1, volume,level, ssid, totalsize, grp, client, name, nfiles, metric, type) VALUES ('$sscreate1 $sscreate2','$sscomp1 $sscomp2','$volume','$level', '$ssid', '$totalsize', '$group', '$client', '$name', '$nfiles', '$metric', '$type')");
print "$sscreate1"; print " $sscreate2"; print " $sscomp1"; print " $sscomp2"; print " $volume"; print " $level"; print " $ssid";print " $totalsize";print " $group";print " $client";print " $name";print " $nfiles";print " $metric";print " $type\n"
} # end of foreach
$db->Close();
All help is welcome
Thanks,
NM
I try to create a perl script which execute a command and to receive the information (output) from a the command into variables of perl and to store them in a database.
Works fine! Except when there is a space in the output, like name:”VSS Data” this generate a problem in storing the information into the database.
Is there a way to tell Perl that the first 20 charaters of the ouput belongs to the first variable ($sscreate1) and the the next 20 by $sscreate2 etc.
This is the script I created:
#!C:/perl/bin/perl.exe
use Win32::ODBC;
$db = new Win32::ODBC("TestDB");
open (MM, 'mminfo -s Server –r "sscreate(20),sscomp(20),volume(20),level,ssid,totalsize,group,client,name(64),nfiles, metric, type" -t "2 week ago" |') || die "Cannot get mminfo report\n"; @bsinfo = <MM>;
foreach (@bsinfo) { ($sscreate1, $sscreate2, $sscomp1, $sscomp2, $volume, $level, $ssid, $totalsize, $group, $client, $name, $nfiles, $metric, $type) = split;
if ($sscreate1 eq "sscreate1") { next; }
$db->Sql("INSERT INTO NW_SAVESETS (sscreate1, sscomp1, volume,level, ssid, totalsize, grp, client, name, nfiles, metric, type) VALUES ('$sscreate1 $sscreate2','$sscomp1 $sscomp2','$volume','$level', '$ssid', '$totalsize', '$group', '$client', '$name', '$nfiles', '$metric', '$type')");
print "$sscreate1"; print " $sscreate2"; print " $sscomp1"; print " $sscomp2"; print " $volume"; print " $level"; print " $ssid";print " $totalsize";print " $group";print " $client";print " $name";print " $nfiles";print " $metric";print " $type\n"
} # end of foreach
$db->Close();
All help is welcome
Thanks,
NM