NAME

XAS::Lib::WS::Transfer - A class to transfer files with WS-Manage

SYNOPSIS

 use Try::Tiny;
 use XAS::Lib::WS::Transfer;

 my $trans = XAs::Lib::WS::Transfer->new(
   -username    => 'Administrator',
   -password    => 'secret',
   -url         => 'http://windowserver:5985/wsman',
   -auth_method => 'basic',
   -keep_alive  => 1,
 );

 try {

     if ($trans->create) {

         if ($trans->exists('test.txt')) {

             $trans->del('test.txt');

         }

         $trans->put('junk.txt', 'test.txt');

         my $output = $trans->dir('.');
         printf("%s\n", $output);

         $trans->destroy;

     }

 } catch {

     my $ex = $_;
     $trans->destroy;
     die $ex;

 };

DESCRIPTION

This package implements a crude method of performing file operations with a Windows based WS-Manage server. These methods should be wrapped in an exception handling block to trap errors. If not, resources will not be freed on the remote server. You have been warned.

METHODS

new

This module inherits from XAS::Lib::WS::RemoteShell and takes the same parameters.

get($remote, $local)

Retrieve a file from the remote server. This is very memory intensive operation as the file is converted to base64 and dumped to stdout on the remote end. This blob is then buffered on the local side and converted back to a binary blob before being written out to disk. This method can be used to transfer binary files.

$local

The name of the local file. Paths are not checked and any existing file will be over written.

$remote

The name of the remote file.

put($local, $remote)

This method will put a file on the remote server. This is an extremely slow operation. The local file is block read and the buffer is converted to base64. This buffer is then stored within a script that will be executed to convert the blob back into a binary stream. This stream is then appended to the remote file. Not recommended for large files. This method can be used to transfer binary files.

$local

The name of the local file.

$remote

The name of the remote file. Paths are not checked and any existing file will be appended too.

exists($path)

This method checks to see if the remote path exists. Returns true if it does.

$path

The name of the path.

del($filename)

This method will delete a remote file. Returns true if successfull.

$filename

The name of the file to delete.

mkdir($path)

This method will create a directory on the remote server. Intermediate directories are also created. Returns true if successful.

$path

The path for the directory.

rmdir($path)

This method will remove a directory for the the remote server. Returns true if successful.

$path

The name of the directory to remove.

dir($path)

This method will return a listing of a directory on the remote server. No effort to format the listing is made. This is the raw output.

$path

The name of the directory to perform the listing on.

SEE ALSO

XAS::Lib::WS::Base
XAS::Lib::WS::RemoteShell
XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (c) 2012-2016 Kevin L. Esteb

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.