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: Problem with Javascript with TDC control
    ... The problem is in getting the total after doing a display and then refreshing the TDC (which invokes the script filter()). ... I tried to put similar looping code at the end of filterto examine what I get from the TDC refresh, but I got a messages of "Operation is not allowed when the object is closed". ... The call of a filter is done in a javascript routine with setting the DataURL and doing inquiry.Resetwhere inquiry is the name of the dataset object. ...
    (comp.lang.javascript)
  • 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: pointfree notation
    ... Sorry that the first post was mangled, ... Here is the intended posting. ... and leave its result and the other for filter; ... stdIn:40.1-40.31 Warning: type vars not generalized because of value ...
    (comp.lang.functional)
  • Re: SSH login automation, get stuck at the last step.
    ... puts "$output" ... The $output will print out a warning like: ... refer to the manual step result on my first post) ... Have you tried to adapt the script I wrote in a previous post? ...
    (comp.lang.tcl)