Open main menu

CDOT Wiki β

Changes

no edit summary
{|cellpadding="15" width="100%"
|-
|'''Script #1: Generate a Simple Report:<br>''' [ [https://scs.senecac.on.ca/~murray.saul/text-report.bash text-report.bash] ]<br>'''Sample output:''' [ [https://scs.senecac.on.ca/~murray.saul/report.txt /root/report.txt] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''exit''' command</li><li>USER '''Environment Variable'''</li><li>'''redirection''' (both &gt; and &gt;&gt;)</li><li>'''command substitution'''</li></ul></blockquote>'''Practical Consideration for scripting in lab1:'''<br><blockquote> Students create simple bash shell script, add elements, then have them copy and paste, then run this script. Key elements related to the script is evaluated and provides basis for other scripting tasks in other labs? Should midterm and/or final exam contain a scripting question? (recommended)<br><br>
|[[Image:lab1-script-text-report.png|thumb|left|400px|When executed as '''root''' or using '''sudo''' command, script generates a basic text-based report in a file]]
|}
{|cellpadding="15" width="100%"
|-
|'''Script #2 Generate Report Graphically:''' [ [https://scs.senecac.on.ca/~murray.saul/report.bash report.bash] ]<br>'''Sample output:''' [ [https://scs.senecac.on.ca/~murray.saul/report.bash txt /root/report.bashtxt] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''exit''' command</li><li>USER '''Environment Variable'''</li><li>'''redirection''' (both &gt; and &gt;&gt;)</li><li>'''zenity'''</li><li>'''for''' loop</li><li>'''command substitution'''</li><li>'''sed'''</li><li>'''set''' command ('''positional parameters''')</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab1:<br><blockquote>''' Students use '''wget''' to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of more advanced shell script(s)''', to see where the commands are being used (from previous shell script), but are '''not required to understand more complex elements''' of these shell scripts.<br><br>
|[[Image:lab1-script-1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to '''start''' VMs]]
|[[Image:lab1-script-2.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to stop '''running''' VMs]]
::'''Scripting for Lab2'''. Lab 2 could be modified to have students create or be exposed to shell scripts with use the '''virtual shell''' ('''virsh''') to '''display in zenity available VMS in checkbox form to select and launch'''. Likewise, script can be launched to '''display in zenity VMs that are currently running in order to shutdown''' (perhaps in same fashion as a zenity dialog box).
 
 
{|cellpadding="15" width="100%"
|-
|<blockquote>'''Script #1: Backup VM images:''' [ [https://scs.senecac.on.ca/~elizabeth.kopiec/backupVM.bash backupVM.bash] ]<br>'''Sample output:''' [ [https://scs.senecac.on.ca/~elizabeth.kopiec/VMBackupOutput.png Output Image] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>If and Else If (elif) - With numerical and string comparisons in the test statement</li><li>User Input (read statement)</li><li>For loop with a hard coded list</li><li>Echoing a variable to grep to validate input</li><li>Checking exit status of previous command (should be a review from ULI101)</li><li>gzip command</li><li>Environment variables</li><li>x</li><li>x</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab 2:'''<br><blockquote> TBD<br><br>
|[[Image:vm-backup-text.png|thumb|left|375px|When executed as '''root''' or using '''sudo''' command, allows for selection of VM images in '''/var/lib/libvirt/images''' directory and backs-up user's home directory (allow option to copy all or by vm #]]
|}
 
{|cellpadding="15" width="100%"
|-
|<blockquote>'''Script #2: Backup VM images (Graphical):'''<br>[ ] (to be created)<br><br>'''Scripting Skills:'''<blockquote><ul><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>'''zenity'''</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>''' Students use '''wget''' to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of more advanced shell script(s)''', to see where the commands are being used (from previous shell script), but are '''not required to understand more complex elements''' of these shell scripts.<br><br></blockquote>
|[[Image:lab2-backup-image-2.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, allows for selection of VM images in '''/var/lib/libvirt/images''' directory and backs-up to various media options]]
|}
{|cellpadding="15" width="100%"
|-
|<blockquote><blockquote>'''Script #1 3 :Start/Stop VMs (graphicallytext-based):'''<br>[ [https://scs.senecac.on.ca/~murray.saul/vm-start-text.bash vm-start-text.bash] ] [ [https://scs.senecac.on.ca/~murray.saul/vm-stop-text.bash vm-stop-text.bash] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''for''' loop</li><li>'''Command Substitution'''</li><li>Advanced '''awk'''</li><li>'''positional parameters'''</li><li>The '''sed'''</li><li>'''IO Stream vs Graphical Interaction"Here" Document''' (eg. zenity)</li><li>'''Scripting Samples (View and adapt)'''- don't "re-invent the wheel completely"redirection within command)</li><li>'''virsh''' command</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>''' Students use '''wget''' to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of more advanced shell script(s)''', to see where the commands are being used (from previous shell script), but are '''not required to understand more complex elements''' of these shell scripts.<br><br></blockquote>|[[Image:lab2-script-1lab2_text_1.png|thumb|left|175px275px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to '''start''' VMsin a text-based interface]]|[[Image:lab2Lab2-backup-scriptimage-21.png|thumb|left|175px275px|When executed as '''root''' or using '''sudo''' command, provides VM status and opportunity to stop '''running''' VMsin a text-based interface]]
|}
{|cellpadding="15" width="100%"
|-
|<blockquote><blockquote>'''Script #24 : Backup VM imagesStart/Stop VMs (graphically):'''<br>[ [https://scs.senecac.on.ca/~murray.saul/vm-start.bash vm-start.bash] ] [ [https://scs.senecac.on.ca/~murray.saul/vm-stop.bash vm-stop.bash] ] (to be created)<br><br>'''Scripting Skills:'''<blockquote><ul><li>x'''if''' statement</li><li>x'''for''' loop</li><li>x'''Command Substitution'''</li><li>xAdvanced '''awk'''</li><li>x'''positional parameters'''</li><li>x'''sed'''</li><li>x'''IO Stream vs Graphical Interaction''' (eg. zenity)</li><li>x</li><li>x'''virsh''' command</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>''' Students use '''wget''' to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of more advanced shell script(s)''', to see where the commands are being used (from previous shell script), but are '''not required to understand more complex elements''' of these shell scripts.<br><br></blockquote>|[[Image:lab2-script-31.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, allows for selection of provides VM images in status and opportunity to '''start''' VMs]]|[[Image:lab2-script-2.png|thumb|left|175px|When executed as '''root''' or using '''/var/lib/libvirt/imagessudo''' directory command, provides VM status and backs-up opportunity to various media optionsstop '''running''' VMs]]
|}
 
== Lab 3:==
 :: This lab deals with software installation and introduction to LVM. Not certain shell scripting would benefit software installation with yum, since can use yum to install multiple instances of software. On the other hand, would be useful to expose students to '''shell scripts that manage LVM for practical situations''' (i.e. case scenarios - real world situations). Should consult with professors and industry SMEs to provide good examples of scripts involving LVM. LVM scripting example should be included in this lab since lab4 is a big lab and keeps students very involved.<br><br>[[Image:lab3_monitor_1.png|thumb|right|375px|When executed as '''root''' or using '''sudo'''Example command, allows for creation of many user accounts (stored in a user database in /root/new-users.txt]]'''Shell script DemoScript #1 (monitor Disk Space):''' [ [[lab3 Shell Script Demo 1|xhttps://scs.senecac.on.ca/~murray.saul/monitor-disk-space.bash monitor-disk-space.bash]] ] <br>(to be createdCourtesy: http://bash.cyberciti.biz/monitoring/shell-script-monitor-unix-linux-diskspace/)<br><br>'''Scripting Skills:'''<blockquote><ul><li>x'''df'''</li><li>x'''grep'''</li><li>x'''awk'''</li><li>x'''command substitution'''</li><li>x'''mail'''</li><li>x'''cut'''</li><li>x'''do-while''' loop</li><li>x</li><li>x'''Cron Tables'''(crontab)</li></ul></blockquote><br>
::'''Practical Consideration for scripting in lab3:<br><br>''' Do students create simple bash shell script, add elements, then have them copy and paste, then run this more complex script? Is lab2 too long for scripting element to be included? Key elements of scripting elements should be contained in information boxes in lab. Should midterm and/or final exam contain a scripting question? (recommended)<br><br>
 
{|cellpadding="15" width="100%"
|-
|'''Script #2 User LVM Management:''' [ ] ??<br><br>'''Scripting Skills:'''<blockquote><ul><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab4:'''<br><blockquote>
'''Practical Consideration for scripting in lab3:''' '''Possible "teachable area" to add as end of lab4 for students to learn manipulating data files for mass (batch) processing'''. Do students create simple bash shell script, add elements, then have them copy and paste, then run this more complex script? Is lab2 too long for scripting element to be included? Key elements of scripting elements should be contained in information boxes in lab. Should midterm and/or final exam contain a scripting question? (recommended)<br><br>
|[[Image:lab3_2.png|thumb|left|375px|When executed as '''root''' or using '''sudo''' command, allows for creation of many user accounts (stored in a user database in /root/new-users.txt]]
|}
== Lab 4:==
{|cellpadding="15" width="100%"
|-
|<blockquote><blockquote>'''Scripting Demo (user account management)Script #1 User Account Management:''' [ [http://cs.senecac.on.ca/~murray.saul/create-users.bash create-users.bash] ]<br>Sample of new employee database: [ [https://scs.senecac.on.ca/~murray.saul/new-users.txt /root/new-users.txt] ]<br><br>'''Scripting Skills:'''<blockquote><ul><li>'''if''' statement</li><li>'''Testing for existence of regular file'''</li><li>'''Arrays'''</li><li>'''Math''' Expressions</li><li>'''exit''' command</li><li>USER '''Environment Variable'''</li><li>'''redirection''' (both &gt; and &gt;&gt;)</li><li>'''useradd'''</li><li>'''for''' loop</li><li>'''command substitution'''</li><li>'''mail'''</li><li>'''awk''' command ('''positional parameters''')</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab4:'''<br><blockquote>'''Practical Consideration for scripting in lab4lab3:''' '''Possible "teachable area" to add as end of lab4 for students to learn manipulating data files for mass (batch) processing'''. Do students create simple bash shell script, add elements, then have them copy and paste, then run this more complex script? Is lab2 too long for scripting element to be included? Key elements of scripting elements should be contained in information boxes in lab. Should midterm and/or final exam contain a scripting question? (recommended)<br><br>
|[[Image:lab4_1.png|thumb|left|375px|When executed as '''root''' or using '''sudo''' command, allows for creation of many user accounts (stored in a user database in /root/new-users.txt]]
|}
== Lab 5:==
:: A shell script could demonstrate the automation downloading to graphically display status of services and start and compiling source code (zipped tarballs)stop them. Could a demonstration of a  {|cellpadding="15" width="100%"spider|-program" with wget command be applicable here? An example of the simpler case would be to obtain a zipped tarbar via url (|<blockquote>'''wgetScript #1: Service Status (start and stop services - Text based):'''), decompress zipped tarball, change to source directory, logic to see if <br>[ [http://cs.senecac.on.ca/~murray.saul/service-start-text.bash service-start-text.bash] ] [ [http://cs.senecac.on.ca/~murray.saul/service-stop-text.bash service-stop-text.bash] ]<br><br>'''./configureScripting Skills:''' command needs to be run, compile and run software or provide error or problems of failure to install software <blockquote><ul><li>'''or this would be a good task for assignment #2if'''. statement<blockquote/li><blockquoteli>OPS435 Elements '''Here document''' (Scripting Demo Contentsredirection):<blockquote/li><li>'''service''' utility<ul/li><li>xgrep</li><li>x'''exit''' command</li><li>xUSER '''Environment Variable'''</li><li>x'''redirection''' (both &gt; and &gt;&gt;)</li><li>xtesting by true-false return of pipeline command</li><li>x'''for''' loop</li><li>x'''command substitution'''</li><li>x'''awk''' command</li><li>x'''positional parameters'''</li></ul></blockquote><br><br>Example '''Practical Consideration for scripting in lab2:<br><blockquote>''' Students use '''wget''' to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of Shell more advanced shell script Demo 1 (automatic download and compile s)''', to see where the commands are being used (from previous shell script), but are '''not required to understand more complex elements''' of soure)these shell scripts.<br><br></blockquote>|[[Image: service_start_1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides Service status and opportunity to start '''non-running''' services]]|[ [[lab5 Shell Script Demo 1Image:service_stop_1.png|thumb|left|175px|x.bashWhen executed as '''root''' or using '''sudo''' command, provides Service status and opportunity to stop '''running''' services]] ] (to be created)|} {|cellpadding="15" width="100%"|-|<brblockquote>Example of Shell script Demo '''Script #2 : Service Status (manipulate start and stop services: Graphical): '''<br>[ ] [[lab5 Shell Script Demo 2|x.bash]] ] (to be createdcompleted)<br><br>'''Scripting Skills:'''<blockquote><ul><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li><li>x</li></ul></blockquote><br><br>'''Practical Consideration for scripting in lab2:<br><blockquote>''' Students use '''wget''' to download existing shell script and run it to see what happens. Students are '''encouraged to view contents of more advanced shell script(s)''', to see where the commands are being used (from previous shell script), but are '''not required to understand more complex elements''' of these shell scripts.<br><br></blockquote>|[[Image:service_start_graphical_1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides Service status and opportunity to start '''non-running''' services]]|[[Image:service_stop_graphical_1.png|thumb|left|175px|When executed as '''root''' or using '''sudo''' command, provides Service status and opportunity to stop '''running''' services]]|}
::Connection with ULI101 Scripting Skills (Course Outline):<br>Connection with OPS435 Scripting Skills (Course Outline):<br><br>'''Practical Consideration for scripting in lab5:''' Do students create simple bash shell script, add elements, then have them copy and paste, then run this more complex script? Is lab2 too long for scripting element to be included? Key elements of scripting elements should be contained in information boxes in lab. Should midterm and/or final exam contain a scripting question? (recommended)<br><br>
== Lab 6:==
13,420
edits