Download presentation
Presentation is loading. Please wait.
Published byEzra Doyle Modified over 8 years ago
1
System Administration HW3 - Shell Script hchung
2
Computer Center, CS, NCTU 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
Computer Center, CS, NCTU 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
Computer Center, CS, NCTU 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
Computer Center, CS, NCTU 5 User Connect Time Statistic - DEMO Hint: $ man last
6
Computer Center, CS, NCTU 6 Spamming System – Sendmail $ sendmail –t < letter Sample letter sendmail(8), base64(1) From: =?UTF-8?B?6auY5omLCg==?= To: =?UTF-8?B?5Y6y5a6zCg==?= Subject: =?UTF-8?B?6auY5omL5Y6y5a6z5LiN57Ch5ZauCg==?= Content-Transfer-Encoding: base64 Content-Type: text/plain; charset=utf-8 5L2g5piv6auY5omL5L2g5Y6y5a6zCuaIkeaYr+mCsea4o+S4jeewoeWWrgo=
7
Computer Center, CS, NCTU 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
Computer Center, CS, NCTU 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 同學您好, 您的 計算機系統管理 學期成績為 %4 分, %5 及格。 若對成績有疑問請直接回信到 ta@nasa.cs.nctu.edu.tw 。 SA助教關心您! %1 %2 %3 %4 %5 hchung@cs.nctu.edu.tw 鍾 翔 0156038 99 有 hwchiu@cs.nctu.edu.tw 邱宏瑋 0156521 55 沒有 %3 %2 計算機系統管理學期成績 Content file and subject (contains escaped characters %i) Table file (uses “\t” as delimiter)
9
Computer Center, CS, NCTU 9 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_t http://nasa.cs.nctu.edu.tw/sysadm/hw3/demo_c http://nasa.cs.nctu.edu.tw/sysadm/hw3/demo_c http://nasa.cs.nctu.edu.tw/sysadm/hw3/output http://nasa.cs.nctu.edu.tw/sysadm/hw3/output Spamming System – Requirements (3/3) Sample result Example options
10
Computer Center, CS, NCTU 10 Spamming System – DEMO Hint getopt(1)
11
Computer Center, CS, NCTU 11 My Ports Manager – DEMO
12
Computer Center, CS, NCTU 12 My Ports Manager – DEMO (List)
13
Computer Center, CS, NCTU 13 My Ports Manager – DEMO (Manage)
14
Computer Center, CS, NCTU 14 My Ports Manager – DEMO (Manage)
15
Computer Center, CS, NCTU 15 My Ports Manager – DEMO (Manage)
16
Computer Center, CS, NCTU 16 My Ports Manager – DEMO (Manage)
17
Computer Center, CS, NCTU 17 My Ports Manager – DEMO (Manage)
18
Computer Center, CS, NCTU 18 My Ports Manager – DEMO (Install)
19
Computer Center, CS, NCTU 19 My Ports Manager – DEMO (Install)
20
Computer Center, CS, NCTU 20 My Ports Manager – DEMO (Install)
21
Computer Center, CS, NCTU 21 My Ports Manager – DEMO (Install)
22
Computer Center, CS, NCTU 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
Computer Center, CS, NCTU 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
Computer Center, CS, NCTU 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
Computer Center, CS, NCTU 25 Hand-in Due & Demo 2012/11/20
26
Computer Center, CS, NCTU 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!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.