1 / 26

System Administration HW3 - Shell Script

System Administration HW3 - Shell Script. hchung. Requirements. User connect time statistic script (10%) Use one-line command to show user connect time statistic. Spamming system (40%) Send massive mails with customized template and database. GUI port manager (50%)

pearltaylor
Download Presentation

System Administration HW3 - Shell Script

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. System Administration HW3 - Shell Script hchung

  2. Requirements • User connect time statistic script (10%) • Use one-line command to show user connect time statistic. • Spamming system (40%) • Send massive mails with customized template and database. • GUI port manager (50%) • Manage your ports with dialog boxes.

  3. User Connect Time Statistic Script – Requirements (1/2) • Use one-line command • The following lines should NOT be counted • User still logged in • shutdown, reboot or other msgs not associated with accounting • log file location • Use environment variable ‘LOG_FILE’ • Default to /var/log/utx.log • Results should be sorted by time • Output format • USER TIME (in seconds)

  4. User Connect Time Statistic Script – Requirements (2/2) • Only pipes (cmd | cmd) and backquotes (`cmd`) are allowed • No temporary files or shell variables (except LOG_FILE) • No “&&” “||” “>” “>>” “<“ “;” “&”

  5. User Connect Time Statistic - DEMO • Hint: $ man last

  6. Spamming System – Sendmail • $ sendmail –t < letter • Sample letter • sendmail(8), base64(1) From: =?UTF-8?B?6auY5omLCg==?=<hchung@cs.nctu.edu.tw> To: =?UTF-8?B?5Y6y5a6zCg==?= <hwchiu@cs.nctu.edu.tw> Subject: =?UTF-8?B?6auY5omL5Y6y5a6z5LiN57Ch5ZauCg==?= Content-Transfer-Encoding: base64 Content-Type: text/plain; charset=utf-8 5L2g5piv6auY5omL5L2g5Y6y5a6zCuaIkeaYr+mCsea4o+S4jeewoeWWrgo=

  7. Spamming System – Requirements (1/3) • $ hw2 [-hv] [-f from_address] [-F from_name] [-s subject] [-c content_file] -t table_file • If neither –f nor –F is provided, use default sender. • Show usage and exit if running with invalid or –h option. • Use –c option to read content from “file” instead of “stdin”. • In –v mode, print out letter instead of sending. • UTF-8 should be supported. • There will be escaped characters in subject and content_file. • %i should be replaced by elements in the table_file • Do NOT need to implement fool-proof.

  8. Spamming System – Requirements (2/3) • Table file • %1 is recipient’s address • %2 is recipient’s name • Use “\t” to split columns • No specific table size %3 %2 計算機系統管理學期成績 %3%2 同學您好, 您的 計算機系統管理 學期成績為 %4分, %5 及格。 若對成績有疑問請直接回信到ta@nasa.cs.nctu.edu.tw。 SA助教關心您! Content file and subject (contains escaped characters %i) Table file (uses “\t” as delimiter) %1 %2 %3 %4 %5 hchung@cs.nctu.edu.tw 鍾 翔 0156038 99 有 hwchiu@cs.nctu.edu.tw 邱宏瑋 0156521 55 沒有

  9. Spamming System – Requirements (3/3) • hw2.sh -f sata@nasa.cs.nctu.edu.tw -F "計算機系統管理助教“ -s "%3 %2 計算機系統管理學期成績" -c demo_c -t demo_t • http://nasa.cs.nctu.edu.tw/sysadm/hw3/demo_t • http://nasa.cs.nctu.edu.tw/sysadm/hw3/demo_c • http://nasa.cs.nctu.edu.tw/sysadm/hw3/output Example options Sample result

  10. Spamming System – DEMO • Hint • getopt(1)

  11. My Ports Manager – DEMO

  12. My Ports Manager – DEMO (List)

  13. My Ports Manager – DEMO (Manage)

  14. My Ports Manager – DEMO (Manage)

  15. My Ports Manager – DEMO (Manage)

  16. My Ports Manager – DEMO (Manage)

  17. My Ports Manager – DEMO (Manage)

  18. My Ports Manager – DEMO (Install)

  19. My Ports Manager – DEMO (Install)

  20. My Ports Manager – DEMO (Install)

  21. My Ports Manager – DEMO (Install)

  22. My Ports Manager – Requirement (1/2) • Use sudo to add/delete ports • Clean all temp files • Use dialog on Freebsd 9 • Fool-proof

  23. My Ports Manager – Requirement (2/2) • Flow • List • Manage • Choose SEVERAL ports • Show dependency • Required by who • Remove • Exit • Install • Prefix • Choose ONE port • By binary • By source • Exit • Exit

  24. My Ports Manager – Hint • dialog(1) • ports-mgmt/pkg_tree • pkg_info, pkg_delete, pkg_add • make install clean BATCH=yes • /usr/ports/INDEX-9 • xargs

  25. Hand-in • Due & Demo • 2012/11/20

  26. Help IRC channel #nctuNASA on freenode Newsgroup cs.course.sysadmin BBS bs2.to board CS-SysAdmin Email ta@nasa.cs.nctu.edu.tw Goto CSCC to ask professional 3F!

More Related