
File Renaming Problem (Please Help...)
Hi I am having trouble renaming a file and I have absolutely no idea
why.
Here is my code:
--- start
{
chomp;
$name = basename($file);
$destname = "$spooldir/$name";
$tmpname = $destname;
$tmpname =~ s/std/incomplete/g; #copy as incomplete before
renaming as std
if (rename("$file","$tmpname") == 0) { print "ren1 failed: $!\n";
Quote:
}
if (rename("$tmpname","$destname") == 0) { print "ren2 failed:
$!\n"; }
print "MOVING COMMAND: mv $file $destname\n";
}
--- end
I am trying to move a file from one directory to another (with an
intermediate step which is necessary
because the final directory has a daemon which will pick up any files
matching *std*)
Here is the output I get when I run the code
--- start
ren1 failed: No such file or directory
ren2 failed: No such file or directory
MOVING COMMAND: mv
/nt/users/zcrks46c_1/firms/spool/tester/teak_FNR_b11ext_1d10_b11e_cf_failures_apr03_10_31.stdf
/nt/users/zcrks46c_1/firms/spool/stdf/teak_FNR_b11ext_1d10_b11e_cf_failures_apr03_10_31.stdf
--- end
The problem is if I run the "MOVING COMMAND" manually there is no
problem.
If I rely on the "rename(src,dest) method it returns an error. Why Why
Why???????