in reply to Can I use Perl to move an entire HTML file on a different server?

See the rename documentation. Renaming a file also works across directories. It does not work across drive letters or volumes. If you need to "move" the file across volumes, you need to use File::Copy to copy the file and then unlink to delete it.

  • Comment on Re: Can I use Perl to move an entire HTML file on a different server?

Replies are listed 'Best First'.
Re^2: Can I use Perl to move an entire HTML file on a different server?
by kjg (Sexton) on Apr 13, 2006 at 09:57 UTC
    Thanks, but the problem I have is referencing the file on the server as this is diferent from the server I am running the script on, this is my move statement at the moment:

    use Win32::ODBC; use File::Copy; move ("http://wwwdev/streams/$Config{'Author'}/$Config{'Ref'}", "http +://wwwybs/ybsone/pipeline/master/13Apr/$Config{'Ref'}") or die "move +failed: S!";
    Have I referenced the file names in the right way (i.e. is http://wwwdev/streams' the correct way to refer to the file)?

    This currently fails for reasons that I don't know.

    I'm not on wwwdev when I run the script BTW.

      The HTTP protocol cannot move or write files. Your idea cannot work. You need to have access to the file system of the target machine.

      Maybe you can use UNC names like this:

      my $machine = 'wwwdev'; my $sharename = 'wwwshare'; my $source = "\\\\$machine\\$sharename\\source\\directory\\filename.tx +t"; my $target = "\\\\$machine\\$sharename\\target\\directory\\new_filenam +e.txt"; rename $source, $target or die "Couldn't move '$source' to '$target' : $!";
        The HTTP protocol cannot move or write files

        well, actually, it can, the PUT method allows to upload files and the HTTP WebDAV extension adds suport for most filesystem operations.

        Thanks that almost works!

        I'm getting permission denied now

        This is my code now:

        my $machine = 'ybslint01'; my $sharename1 = 'wwwdev'; my $sharename2 = 'wwwybs'; my $source = "\\\\$machine\\$sharename1\\streams\\$Config{'Author'}\\$ +Config{'Ref'}"; my $target = "\\\\$machine\\$sharename2\\ybsone\\pipeline\\master\\13A +pr\\$Config{'Ref'}"; rename $source, $target or die "Couldn't move '$source' to '$target' : $!";
        It's giving permission denied on the 'rename' bit. What accesses levels do I need to give to what?

        This is the error:

        Software error: Couldn't move '\\ybslint01\wwwdev\streams\5110\1144336035.htm' to '\\y +bslint01\wwwybs\ybsone\pipeline\master\13Apr\1144336035.htm' : Permis +sion denied at E:\Perlcgi\Pipeline\approve.pl line 189.