Hi there,
I'm writing a perl script to remove a test database and part of that is of course getting rid of all files. So I wrote this to do the job:
Code:
@rm_opendirs = ($orahome . $dsep . $spfile_dir,$orahome . $dsep . "rdbms" . $dsep . "trace");
foreach $dir (@rm_opendirs) {
opendir($fh,$dir) or return("ERROR","Could not open " . $orahome . $dsep . $spfile_dir . " for reading: $! .",$debug_info);
while ($file = readdir($fh)) {
if ($file =~ m/$pattern/i)
{
push(@rm_paths,$dir . $dsep . $file)
}
}
closedir($fh);
}
foreach $path (@rm_paths) {
rmtree($path,1,1);
}
This always results in an "Could not open /u00/app/oracle/product/10.2.0/rdbms/dbs for reading: No such file or directory" (that directory is the one ending with the $spfile_dir variable) message, although that directory exists and the executing user has writing rights on it.
The same behaviour if I create the directory array like this:
Code:
push(@rm_opendirs,$orahome . $dsep . $spfile_dir);
push(@rm_opendirs,$orahome . $dsep . "rdbms" . $dsep . "trace");
The problem does not occur when one of the directories is the only element in the array though. Of course I could copy and paste that part of the script for the second directory, but I don't like that workaround
Any help would be appreciated.
Thank you.