将整个目录从远程计算机(Windows)复制到本地计算机(Windows)的方法是什么。
我尝试在windows_batch资源中使用的方法
xcopy //machinename/foldername/* C:/ /s /e
xcopy \\machinename\foldername\* C:\ /s /e
我收到错误invalid number of parameters
有些人可以纠正我。 ??
答案 0 :(得分:0)
我解决这个问题的方法是使用两个资源:
1)mount以挂载远程目录
2)remote_directory从挂载点到本地点
请注意,mount ressource会在Chef运行结束时通知自己卸载,以避免挂载点停留在服务器上。
Ex with remote file:
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