<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 12.6 shell script 的追蹤與 debug scripts 在執行之前,最怕的就是出現語法錯誤的問題了!那么我們如何 debug 呢?有沒有辦法不需要通過直接執行該 scripts 就可以來判斷是否有問題呢?呵呵!當然是有的!我們就直接以 bash 的相關參數來進行判斷吧! ``` [dmtsai@study ~]$ sh [-nvx] scripts.sh 選項與參數: -n :不要執行 script,僅查詢語法的問題; -v :再執行 sccript 前,先將 scripts 的內容輸出到屏幕上; -x :將使用到的 script 內容顯示到屏幕上,這是很有用的參數! 范例一:測試 dir_perm.sh 有無語法的問題? [dmtsai@study ~]$ sh -n dir_perm.sh # 若語法沒有問題,則不會顯示任何信息! 范例二:將 show_animal.sh 的執行過程全部列出來~ [dmtsai@study ~]$ sh -x show_animal.sh + PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin + export PATH + for animal in dog cat elephant + echo 'There are dogs.... ' There are dogs.... + for animal in dog cat elephant + echo 'There are cats.... ' There are cats.... + for animal in dog cat elephant + echo 'There are elephants.... ' There are elephants.... ``` 請注意,上面范例二中執行的結果并不會有顏色的顯示!鳥哥為了方便說明所以在 + 號之后的數據都加上顏色了! 在輸出的訊息中,在加號后面的數據其實都是指令串,由于 sh -x 的方式來將指令執行過程也顯示出來, 如此使用者可以判斷程序碼執行到哪一段時會出現相關的信息!這個功能非常的棒!通過顯示完整的指令串, 你就能夠依據輸出的錯誤信息來訂正你的腳本了! 熟悉 sh 的用法,將可以使你在管理 Linux 的過程中得心應手!至于在 Shell scripts 的學習方法上面,需要“多看、多模仿、并加以修改成自己的樣式!” 是最快的學習手段了!網絡上有相當多的朋友在開發一些相當有用的 scripts ,若是你可以將對方的 scripts 拿來,并且改成適合自己主機的樣子!那么學習的效果會是最快的呢! 另外,我們 Linux 系統本來就有很多的服務啟動腳本,如果你想要知道每個 script 所代表的功能是什么? 可以直接以 vim 進入該 script 去查閱一下,通常立刻就知道該 script 的目的了。 舉例來說,我們之前一直提到的 /etc/init.d/netconsole ,這個 script 是干嘛用的? 利用 vim 去查閱最前面的幾行字,他出現如下信息: ``` # netconsole This loads the netconsole module with the configured parameters. # chkconfig: - 50 50 # description: Initializes network console logging # config: /etc/sysconfig/netconsole ``` 意思是說,這個腳本在設置網絡終端機來應付登陸的意思,且配置文件在 /etc/sysconfig/netconsole 設置內! 所以,你寫的腳本如果也能夠很清楚的交待,那就太棒了! 另外,本章所有的范例都可以在 [http://linux.vbird.org/linux_basic/0340bashshell-scripts/scripts-20150717.tar.bz2](http://linux.vbird.org/linux_basic/0340bashshell-scripts/scripts-20150717.tar.bz2) 里頭找到喔!加油~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看