Re: problem using -f file operator
- From: "HL" <oded.haim.langford@xxxxxxxxx>
- Date: 27 Dec 2005 23:43:45 -0800
Hi, sorry for the missing information it is my first post here,
I'll try to be more thorough this time.
First, here is the script it is rather short:
#!/usr/local/bin/perl -w
#===============================================================================
use Carp;
use Cwd;
use File::Path;
use Getopt::Long;
use strict;
#===============================================================================
my @tools; # contain the tools for filtering execution
my $model; # contain the name of the model (e.g. 051226)
my $file; # full path to filter definition file.
my $debug = 1;
Getopt::Long::config('default');
GetOptions('tool=s' => \@tools,
'model=s' => \$model,
'file=s' => \$file,
'h|help' => \&usage);
usage() unless( defined $file && defined $model);
my $rmPath = $ENV{'PROJ_HOME'};
open (IN, $file) || confess "Error: can't open $file for reading.
$!\n";
if ( scalar @tools == 0 )
{
@tools = ('MODELS', `find $ENV{PROJ_HOME}/VERIF_TOOLS -maxdepth 1
-type d`);
splice(@tools,1,1);
foreach ( @tools )
{
chomp;
}
}
while ( my $filter = <IN> )
{
chomp($filter);
next if ( $filter =~ m/^.*\s#/ || $filter !~ m/\w/ ); # line is
remarked or empty
foreach ( @tools ) # e.g. MODELS VERIF_TOOLS/Envir
{
next if ( $filter =~ m/^MODEL/ && m/^VERIF_TOOLS/ );
next if ( $filter =~ m/^VERIF_TOOLS/ && m/^MODEL/ );
my $item = "$rmPath/$filter";
my $tool = $_;
# should be different path for MODELS or VERIF_TOOLS
$item =~ s%($tool)%$1/Model_$model% if ( $tool eq 'MODELS' );
if ( $tool =~ m%VERIF_TOOLS/(\w+)% )
{
$tool = $1;
$item =~ s%($tool/)%$1${tool}_$model/%;
}
# carp "Filter: $item\n" if $debug;
if ( -f $item )
{
unlink($item) || carp "Warning: couldn't remove file:
'$item'\n$!";
carp "Remove File: $item \n" if $debug;
}
elsif ( -d $item )
{
rmtree($item) || carp "Warning: couldn't remove dir:
'$item'\n$!";
carp "Remove Dir: $item \n" if $debug;
}
elsif ( -e $item )
{
unlink($item) || carp "Warning: couldn't remove item:
'$item'\n$!";
carp "Remove Item: $item \n" if $debug;
}
else
{
carp "Ignore Item: $item\n" if $debug;
}
}
}
close (IN);
#===============================================================================
sub usage
{
print "\n$0 -tool <name> -model <name> -file <fullpath>
-model: Set name for the tool for which the filters are applied.
-tool : The directory to which the filters are relative.
-file : Set the filter file.
E.g.: pvcs_filter -tool MODELS -model 051227 -file
~/PVCS/filters/filter.txt
pvcs_filter -tool VERIF_TOOLS/Envir -model 051227 -file
filter.txt
\n";
exit 0;
}
Second, when the script is executed $item contains a full path to
existing file:
$item =
'/project/galileo101/orion2v/VERIF_TOOLS/Random/Random_051226/Gunit/Eth_Stum.eu'
The content of $item doesn't contain references to perl variables or
unique characters '@' '$' that may cause some string manipulation. only
regular valid unix full path to a file.
In the case discussed above the problem relates to a regular ascii
file.
Third, running the script remove files from the specified directory:
'/project/galileo101/orion2v/VERIF_TOOLS/Random/Random_051226/Gunit'
but not the: 'Eth_Stum.eu' file.
changing the files' name or the files' content (and leaving the same
name) didn't help get
it removed.
and last here is the files' contents:
#### CONFIG SELECTORS SECTION ####
# $cfg->{'GMII_Ipg'} = new Selector('Random', '12-20');
# $cfg->{'MII_Ipg'} = new Selector('Random', '24-40');
#### CONFIG GEN SELECTORS SECTION ####
# $cfg_gen->{'ConfType'} = new Selector ('0:1' , 'Default','Random' );
.
- Follow-Ups:
- Re: problem using -f file operator
- From: HL
- Re: problem using -f file operator
- References:
- problem using -f file operator
- From: HL
- Re: problem using -f file operator
- From: Paul Lalli
- problem using -f file operator
- Prev by Date: How to handle "\" indicating next line
- Next by Date: Re: why is 0 first?
- Previous by thread: Re: problem using -f file operator
- Next by thread: Re: problem using -f file operator
- Index(es):
Relevant Pages
|
|