CIS 90 - Lesson 14

CIS 90 - Lesson 14

CIS 90 - Lesson 14 Lesson Module Status • Slides – draft • Properties - done • Flash cards – • First minute quiz – done • Web calendar summary – done • Web book pages – done • Commands – done • Lab – done • Supplies () - na • Class PC's – na • Chocolates - bringing • BkBackup hhdteadset charged - done • CCC Confer wall paper - done • Slides & Lab uploaded - done • SSdescopedtotulides copied to thumb bd drive -done • Final project posted - done • Extra credit labs posted - done 1 CIS 90 - Lesson 14 Instructor: Rich Simms Dial-in: 888-450-4821 Dennis Christopher Francisco Passcode: 761867 Rich Abd SarahAstitow Mike D. Online Class Students Alex Christine Steven Richie Nathan Edtson James B.Liz Casady Jason TonySergio Anthony Fernando Aaron Steve MiguelLars Jennifer Rudy Laura P. Songul Stephanie Victor Tanya Mike P. NickJuan Jacob Andrew Luke Adriana Laura S.Olivia Janelle Saulius Email me ([email protected]) a relatively current photo of your face for 3 points extra credit CIS 90 - Lesson 14 Quiz 3 CIS 90 - Lesson 14 [ ] Has the phone bridge been added? [ ] Is recording on? [ ] Does the phone bridge have the mike? [ ] Share slides, putty (rsimms, simmsben, roddyduk), Chrome and Eko VM [ ] Disable spelling on PowerPoint 4 CIS 90 - Lesson 14 More Shell Scripting Objectives Agenda • Use conditionals in scripts • No Quiz • Transfer files between computers • Questions from last week • Archive directories using tar • Getting started (if you haven't already) • Scripting tips • scp • Tarballs • Wrap up = hands on exercise for topic 5 CIS 90 - Lesson 14 QiQuestions 6 CIS 90 - Lesson 14 Questions Any questions on: • Project? • Ex tra credit LbLabs? • Previous course material? 7 CIS 90 - Lesson 14 Housekikeepipgng 8 CIS 90 - Lesson 14 Previous material and assignment 1. Nooabdu labs due today 2. Project is due midnight on 12/8. That’s one week from now. If you haven't started yet, now would be a good time! 3. Extra credit labs are due midnight 12/15. 9 CIS 90 - Lesson 14 Previous material and assignment Spring 2011 Linux Courses http: //ca br illo.e du /pu blica tions /sc he du le /nex t/depar tmen ts /c is.p df 1. CIS 130 (Jim) Shell Programming • Tuesday nights • Meets in room 2501 2. CIS 90 (Rich) Intro to UNIX/Linux • Thursday afternoons • Meets online using CCC Confer only 3. CIS 90 (Jim) Intro to UNIX/Linux • Wednesday afternoons • Meets in room 2501 10 CIS 90 - Lesson 14 Refhfresh 11 CIS 90 - Lesson 14 UNIX/h/Linux Architecture The Shell • Allows users to interact wit h t he computer via a “command line”. • Prompts for a command, parses the Shell command, find s the right program and gets that program executed. • Called a “shell” because it hides the System Applications Commands undliderlying operating system. • Many shell programs are available: sh (Bourne shell), bash (born again KlKernel shell), csh (C shell), ksh (Korn shell). • A user interface and a programming language (scripts). • GNOME and KDE desktops could be called graphical shells 12 CIS 90 - Lesson 14 Shell Scri p ts Some scripts on opus 1) /home/cis90/bin/riddle1 2) /home/cis90/bin/allscripts 3) /etc/sysconfig/network 4) /usr/bin/spell 5) /usr/bin/vimtutor 6) ~/bin /en lig htenment / You have read permission for all these scripts. You can use cat, more, less, or even vi to view them 13 CIS 90 - Lesson 14 Class Exercise Scripting How many of the commands in /bin are really scripts? file /bin/* file /bin/* | grep script file /bin/* | grep script | wc -l How many of the commands in /usr/bin are really scripts? file /usr/bin/* file /usr/bin/* | grep script file /usr/bin/* | grep script | wc -l 14 CIS 90 - Lesson 14 PjtProject Getting Started 15 CIS 90 - Lesson 14 Gettinggpj started on the final project: 1. Create a file in your bin directory named myscript: • Copy from /home/cis90/depot/myscript • or copy and paste template code from: http://simms-teach.com/docs/cis90/cis90final-project.pdf 2. Give yourself full permissions and give CIS 90 group read and execute permissions • chmod 750 myscript 3. Run allscripts and verify your script will run without any errors Instructor reminder: run testscripts to see current status 16 CIS 90 - Lesson 14 Verify that you can run your myscript from allscripts 17 CIS 90 - Lesson 14 Fina l Pro jec t What is allscripts and myscript? #!/bin/bash # # menu: A simple menu template # while true do clear # echo -n " Spring 2009 CIS 90 Projects 1) Bilal # menu: A simple menu template 2) Craig 3) Dan 4) Doug # 5) Duke 6) Edgar D. 7) Edgar O. while true 8) Gabriel 9) George 10) Glen do 11) Jaime 12) Janet 13) Joe F. clear 14) Joe P. 15) Junious 16) Kang echo -n " 17) Lieven 18) Linda 19) Michael CIS90FilPCIS 90 Final Pro jec t 20) Patrick 21) Talley 22) Todd 1) Task 1 23) William 24) Benji 99) Exit 2) Task 2 Enter Your Choice: " read RESPONSE 3) Task 3 case $RESPONSE in 1) # Bilal /home/cis90/hussabil/bin/myscript 4) Task 4 ;; 2) # Craig /home/cis90/langlcra/bin/myscript 5) Task 5 ;; 3) # Dan /home/cis90/conydan/bin/myscript 6) Exit ;; 4) # Doug /home/cis90/kittldou/bin/myscript Enter Your Choice: " ;; 5) # Duke /home/cis90/roddyduk/bin/myscript read RESPONSE ;; 6) # Edgar D. /home/cis90/delacedg/bin/myscript case $RESPONSE in ;; 7) # Edgar O. /home/cis90/ortegedg/bin/myscript 1) # Commands for Task 1 ;; 8) # Gabriel /home/cis90/pantogab/bin/myscript ;; ;; 9) # George /home/cis90/balesgeo/bin/myscript 2) # Commands for Task 2 ;; 10) # Glen ;; /home/cis90/matligle/bin/myscript ;; 11) # Jaime 3) # Commands for Task 3 /home/cis90/cervajai/bin/myscript ;; 12) # Janet ;; /home/cis90/tumajan/bin/myscript ;; 13) # Joe F. 4) # Commands for Task 4 /home/cis90/ferrajoe/bin/myscript ;; 14) # Joe P. ;; /home/cis90/pragejoe/bin/myscript ;; 15) # Junious 5) # Commands for Task 5 /home/cis90/rossjun/bin/myscript ;; 16) # Kang ;; /home/cis90/leekan/bin/myscript ;; 17) # Lieven 6) exit 0 /home/cis90/mambulie/bin/myscript ;; 18) # Linda ;; /home/cis90/donohlin/bin/myscript / ;; 19) # Michael *) echo "Please enter a number between 1 and 6" /home/cis90/georgmic/bin/myscript ;; 20) # Patrick ;; /home/cis90/caseypat/bin/myscript ;; 21) # Talley esac /home/cis90/senantal/bin/myscript ;; 22) # Todd echo -n "Hit the Enter key to return to menu " /home/cis90/krametod/bin/myscript ;; 23) # William read dummy /home/cis90/tumawil/bin/myscript ;; 24) # Benji done /home/cis90/simmsben/bin/myscript ;; 99) exit 0 ;; 18 *) echo "Please enter a number between 1 and 6" ;; esac echo -n "Hit the Enter key to return to menu " read dummy done CIS 90 - Lesson 14 #!/bin/bash # # menu: A simple menu template # allscr ip ts while true do clear echo -n " Spring 2009 CIS 90 Projects The while statement in allscripppts will loop 1) Bilal 2) Craig 3) Dan 4) Doug 5) Duke 6) Edgar D. 7) Edgar O. 8) Gabriel through the code forever 9) George 10) Glen 40) Songul 12) Janet 13) Joe F. 14) Joe P. 15) Junious 16) Kang 17) Lieven 18) Linda 19) Michael 20) Patrick 21) Talley 22) Todd 23) William 24) Benji 99) Exit Enter Your Choice: " read RESPONSE case $RESPONSE in 1) # Bilal /home/cis90/hussabil/bin/myscript ;; 2) # Craig /home/cis90/langlcra/bin/myscript ;; 3) # Dan /home/cis90/conydan/bin/myscript ;; 4) # Doug /home/cis90/kittldou/bin/myscript ;; 5) # Duke /home/cis90/roddyduk/bin/myscript A case statement is used to run the ;; 6) # Edgar D. /home/cis90/delacedg/bin/myscript ;; 7) # Edgar O. /home/cis90/ortegedg/bin/myscript ;; 8) # Gabriel appropriate myscript file in the student's bin /home/cis90/pantogab/bin/myscript ;; 9) # George /home/cis90/balesgeo/bin/myscript ;; 10) # Glen /home/cis90/matligle/bin/myscript ;; directory 40) # Songul /home/cis90/messison/bin/myscript ;; 12) # Janet /home/cis90/tumajan/bin/myscript ;; 13) # Joe F. /home/cis90/ferrajoe/bin/myscript ;; 14) # Joe P. /home/cis90/pragejoe/bin/myscript ;; 15) # Junious /home/cis90/rossjun/bin/myscript ;; 16) # Kang /home/cis90/leekan/bin/myscript ;; 17) # Lieven /home/cis90/mambulie/bin/myscript ;; 18) # Linda /home/cis90/donohlin/bin/myscript ;; 19) # Michael /home/cis90/georgmic/bin/myscript ;; 20) # Patrick /home/cis90/caseypat/bin/myscript ;; 21) # Talley /home/cis90/senantal/bin/myscript ;; 22) # Todd /home/cis90/krametod/bin/myscript ;; 23) # William /home/cis90/tumawil/bin/myscript ;; 24) # Benji /home/cis90/simmsben/bin/myscript ;; For case 99 the exit command is called which causes the 99) exit 0 ;; *) echo "Please enter a number between 1 and 6" script to terminate. The return code of 0 means successful ;; esac echo -n "Hit the Enter key to return to menu " 19 read dummy done CIS 90 - Lesson 14 # # menu: A simple menu template myscript # while true do clear echo -n"n " CIS 90 Final Project 1) Task 1 2) Task 2 3) Task 3 The outer while statement that loops forever 4) Task 4 5) Tas k 5 6) Exit Enter Your Choice: " read RESPONSE case $RESPONSE in 1) # Commands for Task 1 ;; 2) # Commands for Task 2 ;; 3) # Commands for Task 3 ;; 4) # Commands for Task 4 ;; 5) # Commands for Task 5 ;; 6) exit 0 / ;; *) echo "Please enter a number between 1 and 6" ;; esac echo -n "Hit the Enter key to return to menu " 20 read dummy done CIS 90 - Lesson 14 # # menu: A simple menu template myscript # while true do clear echo -n " CIS 90 Final Project 1) Task 1 2) Task 2 This is a single echo command that prints 3) Task 3 4) Task 4 the selection menu for the user 5) Tas k 5 6) Exit Enter Your Choice: " read RESPONSE case $RESPONSE in 1) # Commands for Task 1 ;; 2) # Commands for Task 2 ;; 3) # Commands for Task 3 ;; 4) # Commands for Task 4 ;; 5) # Commands for Task 5 ;; 6) exit 0 / ;; *) echo "Please enter a number between 1 and 6" ;; esac echo -n "Hit the Enter key to return to menu " 21 read dummy done CIS 90 - Lesson 14 # # menu: A simple menu template myscript # while true do clear echo -n"n " CIS 90 Final Project 1) Task 1 2) Task 2 3) Task 3 4) Task 4 5) Tas k 5 6) Exit Enter Your Choice: " read RESPONSE case $RESPONSE in 1) # Commands for Task 1 ;; 2) # Commands for Task 2 ;; This is a case statement.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    108 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us