views:

2189

answers:

4

I have a Perl app that runs some perforce operations, in the end I would like it to upload the results to SharePoint website.

What is the simplest Perl script that can accomplish a task of adding a document to SharePoint?

The script would need to run on Solaris and use as few as possible external libraries as possible (definetely pure classic Perl) getting anything additional installed on these unix boxes is a pain and would have to be done by remote team.

If this can uploading document can easily be done with wget, that would be of interest too. Anyways, I am looking for 1 or a couple liner that's easy to understand.

Thanks in advance for anything.

UPDATES based on comments:

  • Perl Mechanize sounded like a good idea, but for some reason I am not able to authenticate, Error GETing http://sharepoint Unauthorized .... I had this:

my $m = WWW::Mechanize->new();

$m->credentials($user => $pass);

$m->get($url);

But mechanize won't authenticate against sharepoint for some reason.

  • Does anybody have a link or a sample on how to use sharepoint webdav from unix via perl? I installed and tried http://www.webdav.org/perldav tried to open my typical sharepoint site via "dave" webdav browser, but I get ** Unauthorized. ** error. Anybody having luck with the webdav approach with perl on unix?

+1  A: 

Can you use the Webdav interface? Each SharePoint list has a webdav folder associated with it.

Nat
Does anybody have a link or a sample on how to use sharepoint webdav from unix via perl? I installed and tried http://www.webdav.org/perldav tried to open my typical sharepoint site via "dave" webdav browser, but I get ** Unauthorized. ** error. Anybody having luck with this?
Ville M
+6  A: 

This sounds like a job for WWW::Mechanize. It has excellent support for dealing with forms.

Leon Timmermans
+1 for Web::Mechanize, it makes screen-scraping a breeze.
David Precious
Mech sounded like a good idea, but for some reason I am not able to authenticate, Error GETing http://sharepoint Unauthorized ....I had this: my $m = WWW::Mechanize->new();$m->credentials($user => $pass);$m->get($url);Any ideas why this won't work with sharepoint?
Ville M
+1  A: 

Just found an easy way on windows from perlmonks forum:

http://www.perlmonks.org/?node_id=527182
under Windows, you can access a sharepoint site via a UNC name. The URL:
sharepoint.domain.dom/sites/Roboticus/Test
is accessible via:
\\sharepoint.domain.com\sites\Roboticus\Test

just adding as answer to myself, now I got to figure out how to script this from Perl and whether there is way to do the same from script running on unix.

Ville M
Yeah, that is the WebDav interface. Hopefully a simple file copy will just "work".
Nat
A: 

To make NTLM authentication work in WWW::Mechanize you need to use this format

use URI; my $u = URI->new($url); my $host = $u->host; my $port = $u->port; my $hostport = "$host:$port";

$agent->$self->credentials($hostport, $realm, $user, $password);

Ken Venner