Hi
Thanx for ur replies and coming to the topic actually i am working this out in LINUX and here we are using it temporarily for a file which has around 100 include statements and again in each inlcude file there may be around 1 to 10 ranging depinding on the type of device rules file. So here its just parent and a Child level ......
Firstly we want to test it our for at leat 2 to 3 levels of includes within include files. Coming to the fastness as you said it not a big problem about it will be OK if it takes adequate amount of time.
i shall also jus give out a sample code which is presently backing up the files which are not having any inlcude statements and also recursively searching for the inlcude into the Depth........
#!/usr/bin/perl
use strict;
my $first_path = "/opt/netcool/etc/test.rules";
&srch_include($first_path);
my ($incl_full_path , $dir_path, $file_name) ;
sub srch_include
{
my ($main_path) = @_ ;
print " First Sub Path : $main_path \n";
open( FH1, "$main_path") or die " Sub1 Error: $! \n ";
my @main_file_cont = <FH1>;
my $count = 0;
foreach my $main_file_line ( @main_file_cont )
{
if( $main_file_line =~ /^(\s+)?include\s+"(.*)"$/)
{
my $count++;
$incl_full_path = $2 ;
print " Inlcudes :: $incl_full_path \n ";
$incl_full_path =~ /(.*\/)(.*)/;
$dir_path = $1 ;
$file_name = $2;
print " Dir : $dir_path File : $file_name \n ";
system ("mkdir -p /root/msk/$dir_path");
sleep 2 ;
open(CR, ">/root/msk/$incl_full_path") or die " Main
+ File Error: $! \n";
print CR " @main_file_cont ";
close(CR);
&srch_include($incl_full_path);
}
}
if($count == 0 )
{
#print " $incl_full_path has No includes and lookup \n ";
$incl_full_path =~ /(.*\/)(.*)/;
$dir_path = $1 ;
$file_name = $2;
#print " Dir : $dir_path File : $file_name \n "
system ("mkdir -p /root/msk/$dir_path");
sleep 2 ;
open(CR, ">/root/msk/$incl_full_path") or die " No Includ
+e Error: $! \n";
print CR " @main_file_cont ";
close(CR);
}
}
here i am able to back the files with no inlcude statements and also the files which has inlcudes i am backing up the main file too and then searching and gooing into the depth .
So jus check ot out and i shall be waiting for ur replies and thank you very much for ur help....
Work Hard Party Harderrr!!
Sushil Kumar
|