我有一个applescript,用于将文件(使用rsync)从源复制到多个位置:
set Servers to {"afp://service.username:password@MACSERVER1.domain.com/Public/", "afp://service.username:password@MACSERVER2.domain.com/Public/", "afp://service.username:password@MACSERVER3.domain.com/Public/", "afp://service.username:password@MACSERVER4.domain.com/Public/", "afp://service.username:password@MACSERVER5.domain.com/Public/"}
--these are constant so no need to change
set Source to "/Shared Items/Public/DeployStudio/Masters/HFS/Sierra.hfs.dmg"
set Destination to "/Volumes/Public/DeployStudio/Masters/HFS"
--the scripts that goes recursively through the list of servers
repeat with i from 1 to count of Servers
set thisServer to item i of Servers
--this will mount each server destination in turn creating a /Volumes/Public folder
mount volume thisServer
--these are two rsync scripts which creates logfiles
do shell script "/usr/bin/rsync -rlptD --log- file=/Users/username/Documents/logs/Sierra-rsync.log " & (quoted form of Source) & " " & (quoted form of Destination)
--not sure this is needed but added this 5 sec delay to stop ejecting disk errors
delay 5
--eject the mounted volume so we don't have multiple Public folders
tell application "Finder"
eject disk "Public"
end tell
end repeat这是很好的工作,并产生一个日志,它所做的。除非有什么问题。然后它就会退出。我想要改变它,这样它就会忽略错误并继续进行下去。有什么想法吗?谢谢
发布于 2016-11-21 17:12:06
若要忽略重复循环中的错误,请将受影响的代码包装在try块中。
repeat with i from 1 to count of Servers
set thisServer to item i of Servers
try
...
end try
end repeathttps://stackoverflow.com/questions/40725456
复制相似问题