Hi Jeff & Wags. David --- Senior Programmer Analyst --- Wgo Wagner wrote: > Smith Jeff D wrote: > > I am trying to copy/move files under WinNT from remote server(s) to > > a central server using File::Copy --see code snippet below: > > > > snippet begins------ > > use File::Copy; > > ...... > > > > open (LOGFILE, ">>testlog") or die (print "$! problem opening > > testlog\n"); print LOGFILE "$date: \n"; > > print LOGFILE "This is a test of moving a handle--ONCE AGAIN\n"; > > print LOGFILE "the end\n"; > > > > #my $result = copy ($fromdir, $todir) or die ("Error--can't copy > > LogFile : $!\n");
This looks as though you're trying to copy a directory? Where did $fromdir and $todir come from? Glad to see it's commented out. > > my $result = move (\*LOGFILE, $todir) or die ("Error--can't move the > > LogFile: $!\n"); You're using the original write-only filehandle you used to append to the log file. a) You won't be able to read from this handle to copy the data. b) The data is more than likely still buffered as it hasn't been flushed. c) While the file is open you can't delete it, and so can't move it. > > > > > > close (LOGFILE); > > > > ....... > > > > > > > > > > > > snippet ends---- > > > > It works fine when I pass it a literal reference for the source and > > destination using copy or move commands. However, I can't get a > > reference to a file handle to work. There must be something really > > simple that I'm missing. I know that it's not a permissions issue > > and I know the file does get created once I've closed the File > > Handle. I'd like to keep the file handle open though so that I can > > grab the contents of the File Handle for another routine. You mean you want to read the contents of the log file that you've already written? > > The move > > command always returns 0 when referencing the LOGFILE file handle. > > I'd like to use move so I don't have to copy the files and remove > > them from the source directory afterwards. As I said, I don't believe you can delete a file while it's open, although under VMS you can mark it to be deleted when it is closed. That may be possible on your platform. > > Jeff, I am running 5.6.0 but when I look at copy using filehandle I > see : > > > use File::Copy cp; > $n=FileHandle->new("/dev/null","r"); > cp($n,"x");' > > which is not what you are trying. You are trying to use an already > open file and that I don't believe is the context of what I see in > the doc. The group can correct me ( and they will) if I am wrong. cp() is a synonym for copy(). The 'new' method of FileHandle is similar to open(), so the above is like: open $n, "< /dev/null"; copy ($n, "x"); and $n is a glob reference. But what good you would be doing by copying from the null device I don't know! Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]