List Info

Thread: Re: Problem Getting File Name from result of dir *.sql




Re: Problem Getting File Name from result of dir *.sql
country flaguser name
United States
2007-03-19 09:42:16

Pat,

have you run it through debugger?

Bob

sailorpat2 < pat.hall%40gilbarco.com">pat.hallgilbarco.com> wrote:
Can't figure out why the following code will not give me the file
name correctly.

open (FH,">>process.txt&quot;);
print FH "[$timestamp] $directory.nn";
close (FH);
backup_files=`dir $directory\*.sql >q_backups.txt`;
#print "dir $directory\*.sql >q_backups.txtn&quot;;
open(FH,"q_backups.txt");
backup_files=<FH&gt;;
close(FH);
open (FH,">>message.txt&quot;);
print FH "[$timestamp] The following MySQL backup
files have been deleted from $directory...nn";;
$q_count=0;
foreach $file (backup_files) {
chomp $file;
parts=split/s/,$file;
chomp $parts[0];
if (((check_date($parts[0]) == 1)) && ($parts
[18] ne ".&quot;) && ($parts[18] ne "..&quot;) && ($parts[0] lt $threshold))
{
parts=split/s/,$file;
chomp $parts[1];
$fname[1]=substr($file[1],40,29);
$parts[1]=&quot;s".$parts[1];

print FH "-- $fname[1]n";
print FH "- $parts[1]n";
$q_count=$q_count+;1;

The $fname is blank
The $parts doesn't have the file name correctly. It has:
sql 20061219 2045.

File name should be: Backup_mysql 20061219 2045.sql

This is the whole line I'm reading from the dir results file:
12/19/2006 09:45 PM 345,984 Backup_mysql 20061219 2045.sql

The time stamp part works.

What I'm trying to do is delete files in a directory based on their
timestamp.

Pat

---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )