Thanks for adding your code. Now we can get down to business. I looked at your code, and it seemed to me that you had too much going on. I didn't see any reason for
Getopt::Long; LWP::Debug has been deprecated, and I took out
SOAP::Lite. This is how I would approach it:
#!/usr/bin/perl
use strict;
use warnings;
use HTTP::DAV;
my $source = "/home/jadli_r/sharepoint_test/test.txt";
my $destination = "https://fddld.com/sites/A055/files/";
my $username = "uname";
my $password = "passwd";
my $ua = HTTP::DAV::UserAgent->new( keep_alive => 1 );
my $dav = new HTTP::DAV( -useragent => $ua );
$dav->credentials( -user => $username,
-pass => $password,
-url => $destination,
-realm => "DAV realm",
);
$dav->open( -url => $destination )
or die("Couldn't open $destination: " .$dav->message . "\n");
$dav->lock( -url => $destination, -timeout => "infinity" )
or die "Put requires infinity\n";
if ( $dav->put( -local => $source, -url => $destination ) ) {
print "Successfully uploaded $source to $destination\n";
}
else {
print "Put failed: " . $dav->message . "\n";
}
Note that I'm not sure that you'll need keep_alive with an
infinite lock.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.