Hi,
Here is my script, I
am comparing two txt files which are pipe delimited line by line if they match
then their is no output but if they do not match then it gives an
output
about the difference
My both files are loaded in the array and I am
comparing line by line
How can I compare a value in a certain field within an
array line by line between two files so that I can have result I want
instead of comparing whole line
The txt files are attached for your visual ease
they are not pipe delimited and the field names are displayed, In the script
they will be
pipe delimited without any field name or
header
If you can help me out
thanks
my($snapshot, $baseline); # Defining txt
files
# First file
$snapshot = "./302-snap.txt"; # List of Svcs currently running loc at c:\perl
$snapshot = "./302-snap.txt"; # List of Svcs currently running loc at c:\perl
# Second file
$baseline = "./302-base.txt"; # List of All Svcs which should be running
$baseline = "./302-base.txt"; # List of All Svcs which should be running
my(@arr1, @arr2, @result); # Defining
arrays
my($fld1, $fld2, $fld3, $fld4); # Defining variables for fields
my($match, $cnt, $val1, $val2, $finalresult); # Defining scalar variables
$match = "N";
my($fld1, $fld2, $fld3, $fld4); # Defining variables for fields
my($match, $cnt, $val1, $val2, $finalresult); # Defining scalar variables
$match = "N";
#Open snapshot file and insert every line into
@arr1
open(SNAPSHOT, $snapshot) or die "Unable to open $snapshot."; # Open the txt file and place it in filehandle
open(SNAPSHOT, $snapshot) or die "Unable to open $snapshot."; # Open the txt file and place it in filehandle
$cnt = 0;
while ( <SNAPSHOT> ) # Looping thru the filehandle snapshot
{
$arr1[$cnt] = $_;
$cnt = $cnt + 1;
}
close (SNAPSHOT); # close the filehandle snapshot
while ( <SNAPSHOT> ) # Looping thru the filehandle snapshot
{
$arr1[$cnt] = $_;
$cnt = $cnt + 1;
}
close (SNAPSHOT); # close the filehandle snapshot
#Open baseline file and insert every line into
@arr2
open(BASELINE, $baseline) or die "Unable to open $baseline."; # Open the txt file and place it in filehandle
open(BASELINE, $baseline) or die "Unable to open $baseline."; # Open the txt file and place it in filehandle
$cnt = 0;
while ( <BASELINE> ) # Looping thru the filehandle baseline
{
$arr2[$cnt] = $_;
$cnt = $cnt + 1;
}
close (BASELINE); # close filehandle baseline
while ( <BASELINE> ) # Looping thru the filehandle baseline
{
$arr2[$cnt] = $_;
$cnt = $cnt + 1;
}
close (BASELINE); # close filehandle baseline
# Outer loop is for baseline file
# Inner loop is for snapshot file
# Taking one element from @arr2 (baseline) and comparing it with all the elements in @arr1(snapshot) and
# If their is no match then insert that name into @result.
# Inner loop is for snapshot file
# Taking one element from @arr2 (baseline) and comparing it with all the elements in @arr1(snapshot) and
# If their is no match then insert that name into @result.
$cnt = 0;
foreach $val2 (@arr2) # referring to baseline
{
foreach $val1 (@arr1) # referring to snapshot
{
if ($val1 eq $val2)
{
$match = "Y";
}
}
if ($match eq "N")
{
$result[$cnt] = $val2;
$cnt = $cnt + 1;
}
foreach $val2 (@arr2) # referring to baseline
{
foreach $val1 (@arr1) # referring to snapshot
{
if ($val1 eq $val2)
{
$match = "Y";
}
}
if ($match eq "N")
{
$result[$cnt] = $val2;
$cnt = $cnt + 1;
}
$match = "N";
}
}
$finalresult = 0; # initializing to zero
foreach $val1 (@result)
{
$finalresult = $finalresult + 1;
}
foreach $val1 (@result)
{
$finalresult = $finalresult + 1;
}
if ($finalresult > 0 )
{
print "\nList of SICK Siebel-Components \n\n"; # If some svc is not functioning
foreach $val1 (@result)
{
($fld1,$fld2,$fld3,$fld4) = split(/\|/,"$val1");# separating req fields for output
print "Svc-Component $fld4, of Siebel-Svc '$fld3'($fld2)\n";
}
}
else
{
print "\nAll Siebel-Components are Functioning Fine\n"; # When all svcs are running fine
}
{
print "\nList of SICK Siebel-Components \n\n"; # If some svc is not functioning
foreach $val1 (@result)
{
($fld1,$fld2,$fld3,$fld4) = split(/\|/,"$val1");# separating req fields for output
print "Svc-Component $fld4, of Siebel-Svc '$fld3'($fld2)\n";
}
}
else
{
print "\nAll Siebel-Components are Functioning Fine\n"; # When all svcs are running fine
}
SBLSRVR_NAME SVC_NAME FULL_NAME SVC_COMP SVC_STATE SVC_STARTUP_STATE START_TIME END_TIME MAX_TASKS DFLT_SERVERS NUM_SCHED_TASKS NUM_RUN_TASKS SVC_STATUS SV MAX_MTS_PROCS ACTIVE_MTS_PROCS TOTAL_MTS_PROCS ------------ ---------------- ----------------------------- ----------- ----------- ----------------- ------------------- ------------------- --------- ------------ --------------- ------------- ---------- -- ------------- ---------------- --------------- S2_NXLKPRD SMECacheMgr Analysis Cache Manager SMECacheMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMEProxyMgr Analysis Proxy Manager SMEProxyMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMEQueryMgr Analysis Query Manager SMEQueryMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD AsgnSrvr Assignment Manager AsgnSrvr Running Running 08/24/2001 11:00:49 2 1 1 1 1 1 S2_NXLKPRD AsgnBatch Batch Assignment AsgnBatch Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD CTIRoute CTI Inbound Call Router CTIRoute Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD Dqmgr Data Quality Manager Dqmgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD DbXtract Database Extract DbXtract Enabled Running 08/24/2001 11:00:49 10 0 1 S2_NXLKPRD MailAgent E-mail Agent MailAgent Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD MailMgr E-mail Manager MailMgr Shutdown Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD EIM Enterprise Integration Mgr EIM Enabled Running 08/24/2001 11:00:49 5 0 1 S2_NXLKPRD EuroWorkMon Europe AM Monitor WorkMon AOR 20 4 0 S2_NXLKPRD FSCyccnt Field Service Cycle Counting FSCyccnt Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD FSRepl Field Service Replenishment E FSRepl Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD GenNewDb Generate New Database GenNewDb Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD GenTrig Generate Triggers GenTrig Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD ICMCalcEngine ICM Calc Engine ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ICMCalcImport ICM CalcWkbk Import ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ICMOrderImport ICM Order Import ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ICompMgr Incentive Compensation Mgr ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ListMgr List Manager ListMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SrGroupMon NEXT SR Group WorkMon AOR 20 4 0 S2_NXLKPRD BGNotifyWFM NEXT-BG-Notify-WFM WorkMon AOR 20 4 0 S2_NXLKPRD NtfyWorkActn NW-Action Ntfy WorkActn AOR 20 4 0 S2_NXLKPRD AssgnWorkMon NW-Monitor Assgn WorkMon AOR 20 4 0 S2_NXLKPRD NtfyWorkMon NW-Monitor Ntfy WorkMon AOR 20 4 0 S2_NXLKPRD SysWorkMon NW-Monitor Sys WorkMon AOR 20 4 0 S2_NXLKPRD ObjMgr Object Manager ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD PageMgr Page Manager PageMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD RTISrvr Real-Time Integration Manager RTISrvr Unavailable Running 08/24/2001 11:00:49 2 0 1 1 0 0 S2_NXLKPRD RepAgent Replication Agent RepAgent Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD SAPBAPIProcessor SAP BAPI Processor RTIBatch Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SAPProcessor SAP IDOC Processor EAI Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SAPReceiver SAP IDOC Receiver EAI Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMECampMgr SME Campaign Manager SMECampMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMECellSvr SME Cell Server SMECellSvr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMESgmntSvr SME Segment Server SMESgmntSvr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD ServerMgr Server Manager ServerMgr Running Running 08/24/2001 11:00:49 20 5 1 S2_NXLKPRD SRMSynch Server Request Manager SRMSynch Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD ReqProc Server Request Processor ReqProc Running Running 08/24/2001 11:00:49 20 1 1 S2_NXLKPRD FSFulfill Service Order Fulfillment Eng FSFulfill Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD FSLocate Service Order Part Locator En FSLocate Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD SCCObjMgr Siebel Call Center ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD SFSObjMgr Siebel Field Service ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD SSEObjMgr Siebel Sales Enterprise ObjMgr Shutdown Shutdown 08/24/2001 11:00:49 20 0 1 1 0 0 S2_NXLKPRD SSVObjMgr Siebel Service Enterprise ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD eChannelObjMgr Siebel eChannel ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD eServiceObjMgr Siebel eService ObjMgr Shutdown Shutdown 08/24/2001 11:00:49 20 0 1 1 0 0 S2_NXLKPRD SynchMgr Synchronization Manager SynchMgr Running Running 08/24/2001 11:00:49 100 1 1 1 1 1 S2_NXLKPRD TxnMerge Transaction Merger TxnMerge Running Running 08/24/2001 11:00:49 10 1 1 S2_NXLKPRD TxnProc Transaction Processor TxnProc Running Running 08/24/2001 11:00:49 1 1 1 S2_NXLKPRD TxnRoute Transaction Router TxnRoute Running Running 08/24/2001 11:00:49 10 10 1 S2_NXLKPRD VitriaWorkMon Vitria Worlflow WorkMon AOR 20 4 0 S2_NXLKPRD WorkActn Workflow Action Agent WorkActn Enabled Running 08/24/2001 11:00:49 5 0 1 S2_NXLKPRD WorkMon Workflow Monitor Agent WorkMon Enabled Running 08/24/2001 11:00:49 5 0 1 55 rows returned. srvrmgr:s2_nxlkprd>
SBLSRVR_NAME SVC_NAME FULL_NAME SVC_COMP SVC_STATE SVC_STARTUP_STATE START_TIME END_TIME MAX_TASKS DFLT_SERVERS NUM_SCHED_TASKS NUM_RUN_TASKS SVC_STATUS SV MAX_MTS_PROCS ACTIVE_MTS_PROCS TOTAL_MTS_PROCS ------------ ---------------- ----------------------------- ----------- ----------- ----------------- ------------------- ------------------- --------- ------------ --------------- ------------- ---------- -- ------------- ---------------- --------------- S2_NXLKPRD SMECacheMgr Analysis Cache Manager SMECacheMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMEProxyMgr Analysis Proxy Manager SMEProxyMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMEQueryMgr Analysis Query Manager SMEQueryMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD AsgnSrvr Assignment Manager AsgnSrvr Running Running 08/24/2001 11:00:49 2 1 1 1 1 1 S2_NXLKPRD AsgnBatch Batch Assignment AsgnBatch Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD CTIRoute CTI Inbound Call Router CTIRoute Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD Dqmgr Data Quality Manager Dqmgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD DbXtract Database Extract DbXtract Enabled Running 08/24/2001 11:00:49 10 0 1 S2_NXLKPRD MailAgent E-mail Agent MailAgent Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD MailMgr E-mail Manager MailMgr Shutdown Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD EIM Enterprise Integration Mgr EIM Enabled Running 08/24/2001 11:00:49 5 0 1 S2_NXLKPRD EuroWorkMon Europe AM Monitor WorkMon AOR 20 4 0 S2_NXLKPRD FSCyccnt Field Service Cycle Counting FSCyccnt Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD FSRepl Field Service Replenishment E FSRepl Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD GenNewDb Generate New Database GenNewDb Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD GenTrig Generate Triggers GenTrig Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD ICMCalcEngine ICM Calc Engine ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ICMCalcImport ICM CalcWkbk Import ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ICMOrderImport ICM Order Import ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ICompMgr Incentive Compensation Mgr ICompMgr Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD ListMgr List Manager ListMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SrGroupMon NEXT SR Group WorkMon AOR 20 4 0 S2_NXLKPRD BGNotifyWFM NEXT-BG-Notify-WFM WorkMon AOR 20 4 0 S2_NXLKPRD NtfyWorkActn NW-Action Ntfy WorkActn AOR 20 4 0 S2_NXLKPRD AssgnWorkMon NW-Monitor Assgn WorkMon AOR 20 4 0 S2_NXLKPRD NtfyWorkMon NW-Monitor Ntfy WorkMon AOR 20 4 0 S2_NXLKPRD SysWorkMon NW-Monitor Sys WorkMon AOR 20 4 0 S2_NXLKPRD ObjMgr Object Manager ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD PageMgr Page Manager PageMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD RTISrvr Real-Time Integration Manager RTISrvr Unavailable Running 08/24/2001 11:00:49 2 0 1 1 0 0 S2_NXLKPRD RepAgent Replication Agent RepAgent Enabled Running 08/24/2001 11:00:49 1 0 1 S2_NXLKPRD SAPBAPIProcessor SAP BAPI Processor RTIBatch Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SAPProcessor SAP IDOC Processor EAI Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SAPReceiver SAP IDOC Receiver EAI Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMECampMgr SME Campaign Manager SMECampMgr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMECellSvr SME Cell Server SMECellSvr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD SMESgmntSvr SME Segment Server SMESgmntSvr Enabled Running 08/24/2001 11:00:49 20 0 1 S2_NXLKPRD ServerMgr Server Manager ServerMgr Running Running 08/24/2001 11:00:49 20 5 1 S2_NXLKPRD SRMSynch Server Request Manager SRMSynch Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD ReqProc Server Request Processor ReqProc Running Running 08/24/2001 11:00:49 20 1 1 S2_NXLKPRD FSFulfill Service Order Fulfillment Eng FSFulfill Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD FSLocate Service Order Part Locator En FSLocate Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD SCCObjMgr Siebel Call Center ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD SFSObjMgr Siebel Field Service ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD SSEObjMgr Siebel Sales Enterprise ObjMgr Shutdown Shutdown 08/24/2001 11:00:49 20 0 1 1 0 0 S2_NXLKPRD SSVObjMgr Siebel Service Enterprise ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD eChannelObjMgr Siebel eChannel ObjMgr Running Running 08/24/2001 11:00:49 20 0 1 1 1 1 S2_NXLKPRD eServiceObjMgr Siebel eService ObjMgr Shutdown Shutdown 08/24/2001 11:00:49 20 0 1 1 0 0 S2_NXLKPRD SynchMgr Synchronization Manager SynchMgr Running Running 08/24/2001 11:00:49 100 1 1 1 1 1 S2_NXLKPRD TxnMerge Transaction Merger TxnMerge Running Running 08/24/2001 11:00:49 10 1 1 S2_NXLKPRD TxnProc Transaction Processor TxnProc Running Running 08/24/2001 11:00:49 1 1 1 S2_NXLKPRD TxnRoute Transaction Router TxnRoute Running Running 08/24/2001 11:00:49 10 10 1 S2_NXLKPRD VitriaWorkMon Vitria Worlflow WorkMon AOR 20 4 0 S2_NXLKPRD WorkActn Workflow Action Agent WorkActn Enabled Running 08/24/2001 11:00:49 5 0 1 S2_NXLKPRD WorkMon Workflow Monitor Agent WorkMon Enabled Running 08/24/2001 11:00:49 5 0 1 55 rows returned. srvrmgr:s2_nxlkprd>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]