1 / 19

第 18 章 自動化工具開發

第 18 章 自動化工具開發. 內容: 自動化工具簡介 Sed 串流編輯器 Awk 資料處理語言 Awk 搜尋敘述與動作 Awk 命令稿 外殼工具發展 Perl 代理管理語言 Perl 發展工具範例. 18-1 自動化工具簡介 (1). 自動化工具的優點 增加可靠性 確實執行工作 增加系統效益 落實經驗傳承 工具類型 系統操作工具 系統檢視工具. 18-1 自動化工具簡介 (2). 發展新工具的工具 - Script. 18-1 自動化工具簡介 (3). 通用型發展工具 - Perl.

meghan
Download Presentation

第 18 章 自動化工具開發

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第 18 章 自動化工具開發 內容: • 自動化工具簡介 • Sed 串流編輯器 • Awk 資料處理語言 • Awk 搜尋敘述與動作 • Awk 命令稿 • 外殼工具發展 • Perl 代理管理語言 • Perl 發展工具範例

  2. 18-1 自動化工具簡介 (1) • 自動化工具的優點 • 增加可靠性 • 確實執行工作 • 增加系統效益 • 落實經驗傳承 • 工具類型 • 系統操作工具 • 系統檢視工具

  3. 18-1 自動化工具簡介 (2) • 發展新工具的工具 - Script

  4. 18-1 自動化工具簡介 (3) • 通用型發展工具 - Perl

  5. 18-1 自動化工具簡介 (4) • 讓工具自動化 - Cron

  6. 18-2 串流編輯器 - sed (1) • Sed 運作模式

  7. 18-2 串流編輯器 - sed (2) • 命令格式 • $ sed [option] ‘instruction’ file • 替換命令 • ‘[address] s/pattern/replcement/flags’ • 刪除命令 • ‘[address]d’ 或 ‘/pattern/d’ • 插入/附加/變更命令 • 附加 – ‘[line-address]a\text’ • 插入 – ‘[line-address]i\text’ • 變更 – ‘[line-address]c\text’ • 列印命令 • ‘[address]p’

  8. 18-3 Awk 資料處理語言 (1) • Awk 命令格式 • $ awk [Option] ‘statement {action}’ input_file • $awk –f program_file input_file

  9. 18-3 Awk 資料處理語言 (2) • Awk 欄位操作 • $0:整筆紀錄的所有資料 • $1 ~ $n:第 1 到 n 欄位 • NF:總共幾個欄位 • NR:總共幾筆紀錄

  10. 18-4 Awk 搜尋敘述與動作 (1) • Awk 處理程序

  11. 18-4 Awk 搜尋敘述與動作 (2) • Awk 搜尋敘述 • 字串搜尋 • 比較符號 • 結合運算 • 指定範圍 • BEGIN 與 END 敘述組合

  12. 18-4 Awk 搜尋敘述與動作 (3) • Awk 指定動作 • 自定與內建變數 • 數值運算與函數 • 陣列 • 自定函數 • 內定函數

  13. 18-5 Awk 命令稿 (1) • 命令稿輸入 • $ awk –f script_file input_file • 命令稿格式

  14. 18-5 Awk 命令稿 (2) • Awk 控制敘述 • if 控制敘述 • while 迴圈敘述 • do 迴圈敘述 • for 迴圈敘述 • break 與 continue 敘述 • 變數傳遞

  15. 18-6 外殼工具發展 (1) • 操作工具發展範例 • chex: 將某一檔案設定成可執行檔。 • diswc:計算輸入檔案的行數與字元數量。 • rm_dir:刪除某一目錄,包含子目錄與檔案。

  16. 18-6 外殼工具發展 (2) • 檢測工具發展範例 • monitor_load:監控系統負荷是否超載。 • monitor_disk:監控磁碟系統是否接近用完。 • check_process:檢查某一應用程式是否正常執行中。 • check_port:檢查某一傳輸埠口是否正常啟動。 • check_account:檢查帳戶檔案是否有被竄改。 • check_passwd:檢查哪一帳戶沒有設定密碼。 • check_hacker:檢查是否有駭客嫌疑者入侵。

  17. 18-7 Perl 代理管理語言 (1) • Perl 基本語法 • 命令行語法 • 命令稿語法

  18. 18-7 Perl 代理管理語言 (2) • Perl 程式語法 • 標準輸入/輸出 • STDOUT • <STDIN> • 魔術符號 • $_ • 變數型態 • 純量變數 • 陣列變數 • 引數陣列 • 雜湊變數

  19. 18-8 Perl 發展工具範例 • 程式範例 • 讀取檔案目錄 – read_dir.pl • 搜尋檔案目錄 – rmCore.pl • 刪除檔案目錄 – rmDir.pl • 監視傳輸埠口 – scanPorts.pl

More Related