2014-09-02 47 views
0

将整个目录从远程计算机(Windows)复制到本地计算机(窗口)的方法是什么。从窗口中的远程位置复制目录

我试图使用windows_batch资源

xcopy //machinename/foldername/* C:/ /s /e 

xcopy \\machinename\foldername\* C:\ /s /e 

我收到一个错误说invalid number of parameters

可以纠正一些我出去的方法。 ??

+0

这似乎并不直接相关的厨师。 – coderanger 2014-09-02 18:29:35

+0

您是否手动运行该命令?像'xcopy \\ remote-box \ tmp \ something \ * C:\ temp/s/e'这样的东西是完全有效的,所以你的Chef食谱可能会使用\作为意外的转义字符 – 2014-09-02 22:53:54

+0

@castling。是的,我尝试手动,它的工作。当我在厨师尝试时,我无法做到。 – 2014-09-03 06:42:08

回答

0

我解决这个问题的方法是使用两个ressources:

1)安装到从安装点安装远程目录

2)remote_directory当地点

注意,安装的ressource通知本身在厨师运行结束时卸载以避免挂载点停留在服务器上。

防爆与远程文件:

share = File::dirname(node['firefox']['http_url']) 
    filename = File::basename(node['firefox']['http_url']) 
    ENV['tmpdrive'] = "Z:" 
    mount "Z:" do 
    action :mount 
    device share 
    username "my_user" 
    domain "my_domain" 
    password "xxxxxx" 
    notifies :umount, "mount[Z:]" 
    end 

    # Wrokaround sous win2k3 
# batch "copy firefox source" do 
# command %Q{xcopy /YZE "Z/#{filename}" "#{ENV['TEMP']}/#{filename}"}.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR) 
# notifies :umount, "mount[Z:]", :immediately 
# end 
    remote_file "#{ENV['TEMP']}/#{filename}" do 
    source "file:///z:/#{filename}" 
    notifies :umount, "mount[Z:]", :immediately 
    end