1849069 Members
6753 Online
104041 Solutions
New Discussion

script help

 
Edgar_8
Regular Advisor

script help

Hi,

Does anyone have a script which could find missing sequences? Here is our scenariio, we receive files
(eg. FILE_yyyymmddhhmmss_nn_ssss, where nn is a particular node number ie. 34 & ssss is a
sequence number ranging from 0001 - 9999) from an external system which is further processed.
What we need to do is run a script daily to ensure that for each node (nn) all its files/sequences for a
day has been received. The output of the script should write to a file all the missing sequnces per node.
Any ideas on how we could script this check?

Thanks in advance!
2 REPLIES 2
H.Merijn Brand (procura
Honored Contributor

Re: script help

# perl -MFile::Find -le'find(sub{m/FILE_\d{14}_(\d\d)_(\d{4})$/ or return;ref$n{$1}or$n{$1}={n=>$2,x=>$2};$n{$1}{n}>$2 and$n{$1}{n}=$2;$n{$1}{x}<$2 and$n{$1}{x}=$2},".");for(sort{$a<=>$b}keys%n){printf"node %2d %4d .. %4d\n",$_,@{$n{$_}}{"n","x"}}'

Would show the list of nodes with the min and max seq received

# perl -MFile::Find -le'find(sub{m/FILE_\d{14}_(\d\d)_(\d{4})$/ or return;ref$n{$1}{$2}++},".");for(sort{$a<=>$b}keys%n){@x=sort{$a<=>$b}values%{$n{$_}};printf"node %2d %4d .. %4d\n",$_,$x[0],$x[-1]'

should do the same using more memory, but is easier to extend to see if the range is complete

# perl -MFile::Find -le'find(sub{m/FILE_\d{14}_(\d\d)_(\d{4})$/ or return;ref$n{$1}{$2}++},".");for(sort{$a<=>$b}keys%n){@x=sort{$a<=>$b}values%{$n{$_}};evalqq{\@y="$x[0]".."$x[-1]"};printf"node %2d %4d .. %4d %s\n",$_,$x[0],$x[-1],"@x"eq"@y"?"complete":"incomplete"'

All off top of my head. Nothing tested

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Mark Grant
Honored Contributor

Re: script help

Merijn,

If that is off the top of your head, I'm glad it's your head, not mine!!
Never preceed any demonstration with anything more predictive than "watch this"