为什么Windows XCOPY在通过psexec通过Perl系统调用调用时失败?
我正在使用psexec在远程
Windows机器上启动Perl程序.该程序对xcopy进行系统调用.这在机器上直接(本地)运行时工作正常,但是当通过psexec远程运行时,xcopy失败并显示以下消息:
(根据用户的不同,该消息可能改为“拒绝访问”.) 注意$!给出以下诊断:
是否通过system()或反引号调用xcopy似乎没有区别. 我应该指出“from”文件夹是一个ClearCase动态视图(M盘). 奇怪的是,当直接从psexec调用时,xcopy似乎正常工作. 以下是其他一些奇怪之处: > xcopy并不总是失败.某些文件似乎只是“被诅咒”.只读属性似乎不是一个因素. 以下是我用来缩小问题的测试Perl脚本的一部分(文件夹名称已经通用化). # ClearCase directory M:STUFFABC contains ABC.tst,ABC.zip and several nonempty subfolders # Directory copy,D drive to D drive #my $cmd = "xcopy D:tempsrc D:tempdest /e /i /y"; # works # Directory copy,M drive to D drive #my $cmd = "xcopy M:STUFFABC D:tempdest /e /i /k /y"; # fails with "File creation error - Incorrect function" or "Access denied" # File copy (.tst),M drive to D drive (trailing backslash) #my $cmd = "xcopy M:STUFFABCABC.tst D:tempdest"; # works! # Directory copy,M drive to D drive (trailing backslash) #my $cmd = "xcopy M:STUFFABC D:tempdest /e /i /k /y"; # copies the .tst file,but fails on the .zip (yes,the .tst file is now getting copied) # Directory copy,M drive to D drive (same as above but without trailing backslash) #my $cmd = "xcopy M:STUFFABC D:tempdest /e /i /k /y"; # copies the .tst file,but fails on the .zip # File copy (.zip),M drive to D drive #my $cmd = "xcopy M:STUFFABCABC.zip D:tempdest"; # fails # File copy (.zip),M drive to D drive (trailing backslash) #my $cmd = "xcopy M:STUFFABCABC.zip D:tempdest"; # fails # After manually (Windows Explorer) copying the .zip file to the dest folder and deleting it # Directory copy,M drive to D drive with /c (continue after failure) #my $cmd = "xcopy M:STUFFABC D:tempdest /c /i /e"; # copies the .tst and .zip file (!),but fails on all other files (folders were successfully created) # After manually copying the Folder1 folder to the dest folder and then deleting it #my $cmd = "xcopy M:STUFFABC D:tempdest /c /i /e"; # copies the .tst and .zip file and the contents of Folder1(!),but fails on all other files # Different dest: my $cmd = "xcopy M:STUFFABC D:tempdest1 /c /i /e"; # Same results as immediately above print "Executing system command: $cmd ...n"; system ($cmd); #print(`$cmd 2>&1`); #same 解决方法
我建议您使用Perl本身而不是使用xcopy命令.有一个模块
File::Copy::Recursive,使用起来非常简单.它不是标准Perl发行版的一部分,因此您必须使用cpan进行安装.
如果您不想使用非本机模块,可以尝试使用File::Find查找目录中的文件,然后将其与File::Copy结合使用. 在Perl Monks上找到了两个示例.一个使用组合,另一个使用File :: Copy :: Recursive 是的,这不是直接回答您的问题,但您应该尽可能避免使用系统命令.当您与系统shell和命令处理器进行交互时(特别是当ClearCase使用文件系统进行攻击时),您最终可能会遇到许多无意的交互,这些交互可能会导致某些情况下的某些情况发生,而其他情况则不然. 要找出系统调用所遇到的问题,您必须假设错误可能在ClearCase,cmd.exe shell,xcopy命令或Perl中.通过不使用系统命令,您已经简化了问题,并且很多时候实际上加快了过程. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Win10 搭建IIS服务
- 如何在Windows上使用git mintty mingw获得彩色输出?
- Windows安装程序 – 启动条件以检测Office 2010应用程序
- Windows Phone 8 HTML5 – 本地与远程HTML性能
- windows-server-2008 – Server Foundation 2012计算机可以
- 防止水龙头通过XAML / WPF中的按钮
- windows-server-2003 – 将NTFS权限分配给具有大量子文件夹
- windows – 临时FTP帐户?
- Windows API一日一练 63 RegOpenKeyEx和RegCreateKeyEx函数
- msxml3.dll错误’80072ee2’操作超时
- 将我的Azure应用程序部署到我的公司本地Windows
- windows-server-2003 – 您是否在Windows服务器上
- windows – 使用Chocolatey创建自己的包
- Windows – IIS 7.5及更高版本 – 在补丁KB29926
- windows-server-2003 – 最佳实践:使用Asp.net和
- windows-explorer – Windows资源管理器附加组件
- 无法在Windows 8上使用SetSystemTime设置时钟
- windows – 使用Nagios(或其他免费产品)监控具有
- 24.Windows任意文件读取漏洞
- active-directory – Windows 7在分支机构上慢速