Re: problem using -f file operator



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' );

.



Relevant Pages

  • Re: Move computers account to another OU from a txt list
    ... I need a script, that list from OU or txt file, that contains machine ... user objects by changing the ADO filter in the loop. ... ' Change the base of the query to a specific OU. ... ' Filter on all user objects. ...
    (microsoft.public.windows.server.scripting)
  • Re: Filtering certain message from expect internal buffer
    ... >>Does anybody know how I can implement a filter that will take certain ... > There's no way to write back to Expect's internal buffer. ... add all kinds of special handling throughout the rest of the script. ... My guess is he is expecting directly on the console & syslog type ...
    (comp.lang.tcl)
  • Re: Create IIS Web Site via ADSI scripting - ISAPI Error
    ... You did not show the code snippet of how you added the Filter. ... When you try to script the configuration, ... When I create the IIS web site manually it all works swimmingly, ...
    (microsoft.public.inetserver.iis)
  • Re: Merge filter inconsistant - MS Replication Problem.zip (0/1)
    ... I have attached the files you need to reproduce the problem. ... create_test_loc.sql - script to create test databases on subscriber ... create_test_rep.sql - script to create test databases on publisher ... fGetCurrentUserID.sql - script to create filter criteria function on ...
    (microsoft.public.sqlserver.replication)
  • Various problems in Baltimores WEBSweeper Script filtering
    ... Various problems in Baltimore's WEBSweeper Script filtering ... WEBsweeper is Baltimore Technologies' Web Content Security solution. ... WEBSweeper includes the ability to filter script from HTML ...
    (Bugtraq)