unix 中用于 BIND 的基本 CSH 脚本中的 nsupdate

nsupdate in basic CSH script for BIND in unix


我从来没有使用过 C,出于安全原因我也没有写这个,我只是写这个脚本来测试通过 nsupdate 对我的 BIND 的更新,特定区域是 "zoneA.unix"。但是我收到 "option: undefined variable"
而且我不确定这是否是通过用户输入执行 nsupdate 的正确方法。

echo "First of all we need to grab your username:"
set uname = $<
 if ($uname == "zoneA")then
 echo "password: "
 set passwd = $<
    if ($passwd == "Azone")then
            echo "you are in"
            echo "now to do the nsupdate"
            echo "do you wish to (A)dd or (D)elete a record"
            set numeric = $<
                    if ($numeric == "A")then
                    $option = "add"
                    $testinga = "add"
                    else if($numeric == "D")then
                    $option = "delete"
                    $testinga = "delete"
                    endif
            echo "what to $testinga to the zone zoneA.unix?"
            set innerzonename = $<
            nsupdate -k /usr/local/etc/namedb/Keys/Kzonea.+157+57916.key -v
            debug yes
            zone zonea.unix
            update $testinga $innerzonename 86400 A 127.0.0.1
            show
            echo "is this correct (Y)es (n)"
            set sendoff = $<
  if($sendoff == "Y")then
  send
  else if ($sendoff == "N")then
  quit
  endif

所以代码在 $option 部分之前工作正常,我不确定它是否会在 nsupdate 期间所需的输入之后工作,因为它不会暂停它,我不知道我怎么能暂停它。

它似乎在做 运行 nsupdate 并等待 nsupdate 完成。不管怎样,我可以把它们传进去吗?

通过这种方式,我所做的就是将 nsupdate 推送到一个文本文件,然后使用 nsupdate -v textile 从文本文件中读取它。此刻似乎很有魅力

if ($uname == "zoneA")then
echo "password: "
set passwd = $<
    if ($passwd == "Azone")then
            echo "you are in"
            echo "now to do the nsupdate"
            echo "do you wish to add or delete a record"
            set numeric = $<
            echo "what to $numeric to the zone zoneA.unix?"
            set innerzonename = $<
            //nsupdate -k /usr/local/etc/namedb/Keys/Kzonea.+157+57916.key
            echo "server "localhost"">>textfiles/stillneedanewname
            echo "debug yes" >> textfiles/stillneedanewname
            echo "zone zonea.unix" >> textfiles/stillneedanewname
            echo "update $numeric $innerzonename.zonea.unix. 86400 A 136.186.230.90" >> textfiles/stillneedanewname
            echo "show" >> textfiles/stillneedanewname
            echo "send" >> textfiles/stillneedanewname
            nsupdate -k /usr/local/etc/namedb/Keys/Kzonea.+157+57916.key -v textfiles/stillneedanewname