in reply to Re^2: Can I use Perl to move an entire HTML file on a different server?
in thread Can I use Perl to move an entire HTML file on a different server?

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' : $!";
  • Comment on Re^3: Can I use Perl to move an entire HTML file on a different server?
  • Download Code

Replies are listed 'Best First'.
Re^4: Can I use Perl to move an entire HTML file on a different server?
by salva (Canon) on Apr 13, 2006 at 11:37 UTC
    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.

      Yes, but I'm not using HTTP in that way, just as part of a file address.
Re^3: Can I use Perl to move an entire HTML file on a different server?
by kjg (Sexton) on Apr 13, 2006 at 10:30 UTC
    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.
      Are you sure that you have share level and NTFS permissions on $sharename1 and $sharename2? That's probably where the error is. You might have to check with an Admin to ensure that the user running the script has the appropriate access to browse to the UNC (Windows browsing through Explorer, not browsing with IE, they are two different animals).
        I'm pretty sure that the permissions are OK.

        If I try and map the address given (in Explorer) it says it can't find it, so that leads me to think that the address isn't formed properly in some way.