I have a Perl app that runs some perforce operations, in the end I would like it to upload the results to SharePoint website.
我有一个运行一些perforce操作的Perl应用程序,最后我希望它将结果上传到SharePoint网站。
- What is the simplest Perl script that can accomplish a task of adding a document to SharePoint?
什么是最简单的Perl脚本可以完成向SharePoint添加文档的任务?
The script would need to run on Solaris and use as few as possible external libraries as possible (definitely pure classic Perl) getting anything additional installed on these unix boxes is a pain and would have to be done by remote team.
该脚本需要在Solaris上运行并尽可能少地使用外部库(绝对纯粹的经典Perl)在这些unix盒上安装任何额外的东西是一件痛苦的事情,并且必须由远程团队完成。
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.
如果这可以很容易地用wget上传文档,那也会引起人们的兴趣。无论如何,我正在寻找一个或一对容易理解的衬垫。
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 ....
Perl Mechanize听起来像个好主意,但由于某种原因我无法进行身份验证,错误获取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.
但机械化不会出于某种原因对sharepoint进行身份验证。
- Does anybody have a link or a sample on how to use sharepoint webdav from unix via perl?
有没有人有关于如何通过perl从unix使用sharepoint webdav的链接或示例?
I installed and tried to open my typical sharepoint site via "dave" webdav browser, but I get ** Unauthorized. **
error.
我安装并尝试通过“dave”webdav浏览器打开我的典型sharepoint网站,但我得到**未经授权。 **错误。
- How to solve it with the webdav approach with perl on unix?
如何使用unix上的perl webdav方法解决它?
5 个解决方案
#1
This sounds like a job for WWW::Mechanize. It has excellent support for dealing with forms.
这听起来像WWW :: Mechanize的工作。它对处理表单有很好的支持。
#2
Just found an easy way on windows from perlmonks forum:
刚刚在perlmonks论坛上发现了一个简单的方法:
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.
只是添加作为自己的答案,现在我必须弄清楚如何从Perl编写脚本,以及是否有办法在unix上运行脚本。
#3
Can you use the Webdav interface? Each SharePoint list has a webdav folder associated with it.
你可以使用Webdav界面吗?每个SharePoint列表都有一个与之关联的webdav文件夹。
#4
To make NTLM authentication work in WWW::Mechanize you need to use this format
要使WWL :: Mechanize中的NTLM身份验证工作,您需要使用此格式
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);
#5
You can connect to SharePoint (or any website) using curl, which is able to authenticate and perform negotiation with Kerberos/NTLM:
您可以使用curl连接到SharePoint(或任何网站),curl能够对Kerberos / NTLM进行身份验证并执行协商:
curl --ntlm -u domain/userid:passwd -T <file> "http://sharepoint URL"
-
--ntlm
(HTTP) Enables NTLM authentication. The NTLM authentication method was designed by Microsoft and is used by IIS web servers. It is a proprietary protocol, reverse-engineered by clever people and implemented in curl based on their efforts. This kind of behavior should not be endorsed, you should encourage everyone who uses NTLM to switch to a public and documented authentication method instead, such as Digest.--ntlm(HTTP)启用NTLM身份验证。 NTLM身份验证方法由Microsoft设计,由IIS Web服务器使用。它是一个专有协议,由聪明人反向设计,并根据他们的努力实现卷曲。不应该认可这种行为,您应该鼓励使用NTLM的所有人切换到公共和记录的身份验证方法,例如Digest。
If you want to enable NTLM for your proxy authentication, then use --proxy-ntlm.
如果要为代理身份验证启用NTLM,请使用--proxy-ntlm。
This option requires a library built with SSL support. Use -V, --version to see if your curl supports NTLM.
此选项需要使用SSL支持构建的库。使用-V, - version来查看你的curl是否支持NTLM。
If this option is used several times, only the first one is used.
如果多次使用此选项,则仅使用第一个选项。
-
-u, --user
Specify the user name and password to use for server authentication. Overrides -n, --netrc and --netrc-optional.
指定用于服务器身份验证的用户名和密码。覆盖-n, - netrc和--netrc-optional。
If you simply specify the user name, curl will prompt for a password.
如果您只是指定用户名,curl将提示输入密码。
The user name and passwords are split up on the first colon, which makes it impossible to use a colon in the user name with this option. The password can, still.
用户名和密码在第一个冒号上分开,这使得使用此选项无法在用户名中使用冒号。密码可以,仍然。
When using Kerberos V5 with a Windows based server you should include the Windows domain name in the user name, in order for the server to successfully obtain a Kerberos Ticket. If you don't then the initial authentication handshake may fail.
将Kerberos V5与基于Windows的服务器一起使用时,应在用户名中包含Windows域名,以便服务器成功获取Kerberos票证。如果不这样做,则初始身份验证握手可能会失败。
When using NTLM, the user name can be specified simply as the user name, without the domain, if there is a single domain and forest in your setup for example.
使用NTLM时,如果您的设置中存在单个域和林,则可以将用户名简单地指定为没有域的用户名。
To specify the domain name use either Down-Level Logon Name or UPN (User Principal Name) formats. For example, EXAMPLE\user and user@example.com respectively.
要指定域名,请使用“低级别登录名”或“UPN(用户主要名称)”格式。例如,分别是EXAMPLE \ user和user@example.com。
If you use a Windows SSPI-enabled curl binary and perform Kerberos V5, Negotiate, NTLM or Digest authentication then you can tell curl to select the user name and password from your environment by specifying a single colon with this option: "-u :".
如果您使用支持Windows SSPI的curl二进制文件并执行Kerberos V5,Negotiate,NTLM或Digest身份验证,那么您可以通过使用此选项指定单个冒号来告诉curl从您的环境中选择用户名和密码:“ - u:” 。
If this option is used several times, the last one will be used.
如果多次使用此选项,将使用最后一个选项。
-
-T, --upload-file
This transfers the specified local file to the remote URL. If there is no file part in the specified URL, Curl will append the local file name. NOTE that you must use a trailing / on the last directory to really prove to Curl that there is no file name or curl will think that your last directory name is the remote file name to use. That will most likely cause the upload operation to fail. If this is used on an HTTP(S) server, the PUT command will be used.
这会将指定的本地文件传输到远程URL。如果指定的URL中没有文件部分,Curl将附加本地文件名。请注意,您必须在最后一个目录上使用尾随/来真正向Curl证明没有文件名,或者curl会认为您的上一个目录名是要使用的远程文件名。这很可能会导致上传操作失败。如果在HTTP(S)服务器上使用它,则将使用PUT命令。
Use the file name "-" (a single dash) to use stdin instead of a given file. Alternately, the file name "." (a single period) may be specified instead of "-" to use stdin in non-blocking mode to allow reading server output while stdin is being uploaded.
使用文件名“ - ”(单个破折号)来使用stdin而不是给定文件。或者,文件名“。” (单个句点)可以指定而不是“ - ”以在非阻塞模式下使用stdin以允许在上传stdin时读取服务器输出。
You can specify one -T for each URL on the command line. Each -T + URL pair specifies what to upload and to where. curl also supports "globbing" of the -T argument, meaning that you can upload multiple files to a single URL by using the same URL globbing style supported in the URL, like this:
您可以在命令行上为每个URL指定一个-T。每个-T + URL对指定要上载的内容和位置。 curl还支持-T参数的“globbing”,这意味着您可以使用URL中支持的相同URL globbing样式将多个文件上载到单个URL,如下所示:
curl -T "{file1,file2}" http://www.uploadtothissite.com
curl -T“{file1,file2}”http://www.uploadtothissite.com
or even
curl -T "img[1-1000].png" ftp://ftp.picturemania.com/upload/
curl -T“img [1-1000] .png”ftp://ftp.picturemania.com/upload/
#1
This sounds like a job for WWW::Mechanize. It has excellent support for dealing with forms.
这听起来像WWW :: Mechanize的工作。它对处理表单有很好的支持。
#2
Just found an easy way on windows from perlmonks forum:
刚刚在perlmonks论坛上发现了一个简单的方法:
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.
只是添加作为自己的答案,现在我必须弄清楚如何从Perl编写脚本,以及是否有办法在unix上运行脚本。
#3
Can you use the Webdav interface? Each SharePoint list has a webdav folder associated with it.
你可以使用Webdav界面吗?每个SharePoint列表都有一个与之关联的webdav文件夹。
#4
To make NTLM authentication work in WWW::Mechanize you need to use this format
要使WWL :: Mechanize中的NTLM身份验证工作,您需要使用此格式
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);
#5
You can connect to SharePoint (or any website) using curl, which is able to authenticate and perform negotiation with Kerberos/NTLM:
您可以使用curl连接到SharePoint(或任何网站),curl能够对Kerberos / NTLM进行身份验证并执行协商:
curl --ntlm -u domain/userid:passwd -T <file> "http://sharepoint URL"
-
--ntlm
(HTTP) Enables NTLM authentication. The NTLM authentication method was designed by Microsoft and is used by IIS web servers. It is a proprietary protocol, reverse-engineered by clever people and implemented in curl based on their efforts. This kind of behavior should not be endorsed, you should encourage everyone who uses NTLM to switch to a public and documented authentication method instead, such as Digest.--ntlm(HTTP)启用NTLM身份验证。 NTLM身份验证方法由Microsoft设计,由IIS Web服务器使用。它是一个专有协议,由聪明人反向设计,并根据他们的努力实现卷曲。不应该认可这种行为,您应该鼓励使用NTLM的所有人切换到公共和记录的身份验证方法,例如Digest。
If you want to enable NTLM for your proxy authentication, then use --proxy-ntlm.
如果要为代理身份验证启用NTLM,请使用--proxy-ntlm。
This option requires a library built with SSL support. Use -V, --version to see if your curl supports NTLM.
此选项需要使用SSL支持构建的库。使用-V, - version来查看你的curl是否支持NTLM。
If this option is used several times, only the first one is used.
如果多次使用此选项,则仅使用第一个选项。
-
-u, --user
Specify the user name and password to use for server authentication. Overrides -n, --netrc and --netrc-optional.
指定用于服务器身份验证的用户名和密码。覆盖-n, - netrc和--netrc-optional。
If you simply specify the user name, curl will prompt for a password.
如果您只是指定用户名,curl将提示输入密码。
The user name and passwords are split up on the first colon, which makes it impossible to use a colon in the user name with this option. The password can, still.
用户名和密码在第一个冒号上分开,这使得使用此选项无法在用户名中使用冒号。密码可以,仍然。
When using Kerberos V5 with a Windows based server you should include the Windows domain name in the user name, in order for the server to successfully obtain a Kerberos Ticket. If you don't then the initial authentication handshake may fail.
将Kerberos V5与基于Windows的服务器一起使用时,应在用户名中包含Windows域名,以便服务器成功获取Kerberos票证。如果不这样做,则初始身份验证握手可能会失败。
When using NTLM, the user name can be specified simply as the user name, without the domain, if there is a single domain and forest in your setup for example.
使用NTLM时,如果您的设置中存在单个域和林,则可以将用户名简单地指定为没有域的用户名。
To specify the domain name use either Down-Level Logon Name or UPN (User Principal Name) formats. For example, EXAMPLE\user and user@example.com respectively.
要指定域名,请使用“低级别登录名”或“UPN(用户主要名称)”格式。例如,分别是EXAMPLE \ user和user@example.com。
If you use a Windows SSPI-enabled curl binary and perform Kerberos V5, Negotiate, NTLM or Digest authentication then you can tell curl to select the user name and password from your environment by specifying a single colon with this option: "-u :".
如果您使用支持Windows SSPI的curl二进制文件并执行Kerberos V5,Negotiate,NTLM或Digest身份验证,那么您可以通过使用此选项指定单个冒号来告诉curl从您的环境中选择用户名和密码:“ - u:” 。
If this option is used several times, the last one will be used.
如果多次使用此选项,将使用最后一个选项。
-
-T, --upload-file
This transfers the specified local file to the remote URL. If there is no file part in the specified URL, Curl will append the local file name. NOTE that you must use a trailing / on the last directory to really prove to Curl that there is no file name or curl will think that your last directory name is the remote file name to use. That will most likely cause the upload operation to fail. If this is used on an HTTP(S) server, the PUT command will be used.
这会将指定的本地文件传输到远程URL。如果指定的URL中没有文件部分,Curl将附加本地文件名。请注意,您必须在最后一个目录上使用尾随/来真正向Curl证明没有文件名,或者curl会认为您的上一个目录名是要使用的远程文件名。这很可能会导致上传操作失败。如果在HTTP(S)服务器上使用它,则将使用PUT命令。
Use the file name "-" (a single dash) to use stdin instead of a given file. Alternately, the file name "." (a single period) may be specified instead of "-" to use stdin in non-blocking mode to allow reading server output while stdin is being uploaded.
使用文件名“ - ”(单个破折号)来使用stdin而不是给定文件。或者,文件名“。” (单个句点)可以指定而不是“ - ”以在非阻塞模式下使用stdin以允许在上传stdin时读取服务器输出。
You can specify one -T for each URL on the command line. Each -T + URL pair specifies what to upload and to where. curl also supports "globbing" of the -T argument, meaning that you can upload multiple files to a single URL by using the same URL globbing style supported in the URL, like this:
您可以在命令行上为每个URL指定一个-T。每个-T + URL对指定要上载的内容和位置。 curl还支持-T参数的“globbing”,这意味着您可以使用URL中支持的相同URL globbing样式将多个文件上载到单个URL,如下所示:
curl -T "{file1,file2}" http://www.uploadtothissite.com
curl -T“{file1,file2}”http://www.uploadtothissite.com
or even
curl -T "img[1-1000].png" ftp://ftp.picturemania.com/upload/
curl -T“img [1-1000] .png”ftp://ftp.picturemania.com/upload/