【发布时间】:2016-09-22 11:14:31
【问题描述】:
我有脚本“proc 备份”。我必须给每个目录很多字来允许或不允许。 我认为与数组集成。但我没有领先...
或者有什么更简单的吗?
bind pubm - "*fertig*" backup
proc backup {nick host handle channel text} {
set name[lindex [split [stripcodes bcru $text]] 2]
set dir[lindex [split [stripcodes bcru $text]] 4]
if {[catch {exec sh backup.sh $dir $name} error]} {
putlog $error
}
putnow "PRIVMSG $channel :backup $name done";
}
array set allowed {
"dir1" "to rar"
"dir2" "backupserver1 "
"dir3" "2016 2017"
}
array set not_allowed {
"dir1" "test crap"
"dir2" "old backupserver2 jpg zip"
"dir3" "2015 2014 2013 2012 2011 2010 209 19"
}
编辑:
来自 irc 的行:( lindex 2 和 4)
仅当名称中的该单词为时才运行 backup.sh
word0 word1 backupserver1 word3 dir2
当另一个单词时不运行备份
word0 word1 backupserver55 word3 dir2
不运行 backup.sh
word0 word1 测试 word3 dir1 word0 word1 废话 word3 dir1
仅当名称中的该单词为时才运行 backup.sh
word0 word1 黑色 word3 dir1
仅当 $name 中允许的集合中的单词是时运行。 当 $name 中的 not_allowed 中有一个单词时不运行。
【问题讨论】:
-
请多写一些关于您预期会发生什么和不会发生什么的信息。现在,我不明白
allowed和not_allowed数组的真正意义是什么。 -
示例:当在 dir1 ($dir) 中的文本包括 ($name) “to” 或 “rar”(允许从数组集)然后 make if {[catch {exec sh backup.sh . ...,当在 dir1 ($dir) 中的文本包括 ($name) "test" 或 "crap" (来自数组集 not_allowed) 然后停止 (retourn 0),我希望它更好。问候