0

将整个目录从远程机器(windows)复制到我的本地机器(windows)的方法是什么。

我在 windows_batch 资源中尝试使用的方法

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

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

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

可以纠正我。??

4

1 回答 1

0

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

1) mount 挂载远程目录

2)从挂载点到本地点的remote_directory

请注意,挂载资源会在厨师运行结束时通知自己卸载,以避免挂载点停留在服务器上。

带有远程文件的 Ex:

  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
于 2014-09-03T09:07:51.590 回答