Week_Three_3x

Download Report

Transcript Week_Three_3x

Week Three Agenda
• Administrative Issues
• Link of the Week
• Review Week Two Information
• This Week’s Expected Outcomes
• Next Lab Assignment
• Break-Out Problems
• Upcoming Deadlines
• Lab Assistance, Questions, and Answers
Administrative Issues
This is the last week for identifying a proctor.
Most students have already selected their
proctor to administer their midterm exam. This
same proctor list will be used for the final
exam unless a change request is submitted to
the Student Learning Center two weeks prior
to the final exam date.
Link of the Week
APA Style writing guidelines will be utilized for all lab
assignment reports .
APA Style Sixth Edition
http://www.apastyle.org/learn/
APA Style Writing Workshop
http://www.franklin.edu/student-services/studentlearning-center/academic-support/workshops.html
Grading will focus mainly on capitalization,
punctuation, grammar, and citation.
Link of the Week
Linux Forums Web Site
This web site allows individuals to post
questions about Fedora Linux and Redhat Linux.
The people that maintain this site are
knowledgeable users of these operating
systems. If your experiencing problems with
commands or just want to learn more about
these systems, you can find this type of
information at this site.
http://www.linuxforums.org/forum/redhat-fedora-linuxhelp/73994-system-commands-not-working-unlesssbin.html
Review Week Two Information
Caveat:
Knoppix software was designed to be used as a Live
CD because of specific features that make it’s
performance and stability very suitable. It has been
noted in several articles that Knoppix works best
from a Live CD. Knoppix enthusiasts have attempted
to install this software on a hard disk and encountered
problems in the process. These problems are most
pronounced when installing updates and new
software.
Review Week Two Information
What is the next user interface going to be?
The textual (command line) and the visual (graphical user)
interfaces are the two most common modalities used to
support engineers in network and system administration
positions. The command line interface is recognized as the
first generation and the graphical user interface is
considered the second generation. Currently, research is
trying to determine the next best interface. The command
line interface is known as, “under the hood” method of
interacting with the operating system.
Review Week Two Information
CLI Benefits:
Manipulate textual data
Quick customization of data allows engineers the ability
to change data to another form
Excellent for filtering data on systems
Commands are rich, expressive, flexible, and powerful
GUI Benefits:
Reduces data overload
Simple filtering and manipulation of the data
Excellent for displaying trends in data
Review Week Two Information
Users can connect the standard output of one command
into the standard input of another command by using the
pipeline operator (|).
Demonstrate
ps -ef
ps –ef | wc –l
ps –ef | awk ‘{print $2}’
ps –ef | grep dandrear
ls –l | cut –c1-3
who | sort > test_file.txt
The output of the who command is piped to the
sort function and written in ascending order in the
test_file.txt file. The “who” and “sort” commands
execute in parallel.
Review Week Two Information
Commands
who –b
who –d
who –r
(time of last system boot)
(print dead processes)
(print current run level)
List directory entries using the ls –l | less command
drwxrwxrwx permissions
-rwxrwxrwx permissions
lrwxrwxrwx permissions
-rwxrwxrwx 2 dandrear
brw-rw---- permissions
crw------Permissions
(directory)
(file)
(Symbolic link)
(Hardlink)
(block)
(character)
Week Two Information
A process associates a number with each file that it has opened. This
number is called a file descriptor. When you log in, your first process
has the following three open files connected to your terminal.
Standard Input (stdin) :
/dev/stdin
File descriptor 0 is open for reading.
Standard Output (stdout):
/dev/stdout
File descriptor 1 is open for writing.
Standard Error (stderr):
/dev/stderr
File descriptor 2 is open reading.
Demonstrate
ls –a > /tmp/output 2>&1
> is equivalent to 1>
< is equivalent to <0
Week Two Information
File Descriptor
Keyboard
#0 stdin
Program
#1 stdout
Display
Screen
#2
stderr
Review Week Two Information
A file descriptor is generally an index for an entry in
a kernel-resident data structure that contains
information on all open files. Each process on the
system has its own file descriptor table. A user
application passes the abstract key to the kernel
through a system call, and the kernel accesses the file
for the application.
A data structure is a specific way of storing and
organizing data in a computer so that it can be
accessed with high efficiently. Data structures can be
used as a single place for storing unrelated
information.
Review Week Two Information
The grep command searches the named input file(s) for
lines containing a given pattern. Each line found is reported
to standard output.
Demonstrate:
grep UNIX foobar_3
grep ‘^UNIX’ foobar_3
grep ‘UNIX$’ foobar_3
grep pattern foobar_1
grep pattern *
The find command lists all pathnames that are in each of the
given directories.
Demonstrate:
find / -type d –print
find ~dandrear –type d -print
find . –print
find / -name foobar
Review Week Two Information
Redirection Symbols:
Redirect the standard output of a command to a file.
date > /tmp/date_saved
Redirect the standard input of a command so that it
reads from a file instead of from your terminal.
cat < ~dandrear/Fall2010_Solutions/test.txt
Append the standard output of a command to a file.
cat foobar_2 >> foobar_1
Review Week Two Information
Korn Shell Syntax and Commands
srchfile.sh $1 $2
original=$PWD
cd $original
cd $2
listing=`ls –l | cut –c57-80`
for file_name in listing
do (boundary)
Action Statements
done (boundary)
Review Week Two Information
Commands
ls –l | more
ls –l | less (count the fields/use “q” to quit)
ls -a
(does not hide entries)
less
man (utilizes the less command for reading
online documentation).
cat > test_file (keyboard input goes into
test_file)
cat < test.txt (test_file is displayed on terminal)
cat foobar_2 >> foobar_1 (append first file to
second file)
Review Week Two Information
Commands
> test_file
cat /etc/passwd
grep x /etc/passwd | cut –d’:’ –f1
chmod 705 *
chmod 705 test_file
grep line ~dandrear/Summer2010_Solutions/foobar_1
find ~dandrear –type d -print
myArray[1]=$1
$0
Review Week Two Information
Commands
The tilde (~) symbol is used to represent the
user’s current home directory (e.g.
/export/home/dandrear)
The command line arguments are:
$0 $1 $2 $3 …
Review Week Two Information
Demonstrate
/export/home/dandrear/.profile
umask 077
The umask variable contains the default permissions
for a file and a directory.
Variables Used by Korn Shell:
HOME = is set to the full path name of your login
directory (/export/home/dandrear)
PATH = contains the command search path. It is set to a
series of path names separated by colons (:).
Review Week Two Information
Variables Used by Korn Shell
SHELL = This entry may be set by the system
administrator to the path name of a shell
interpreter other than the standard bash.
TERM = specifies what terminal you are using.
TMOUT = variable contains the integer attribute. If you
set the value greater than zero, ksh
terminates if you do not enter a command
within the prescribed number of seconds
after ksh issues the PS1 prompt.
MAIL = Name of your Mail files
EDITOR = Pathname for your editor
Review Week Two Information
Man page
Man formats and displays the on-line manual pages. If you
specify section, man only looks at that section of the manual.
Name is normally the name of the manual page, which is
typically the name of a command, function, or file. However,
if name contains a slash (/) then man interprets it as a file
specification.
Each section has an introduction which can be obtained with,
e.g., "man 2 intro“ or “man ./foobar_1”.
If MANPATH is set, man uses it as the path to search for
manual page files.
Review Week Two Information
Man Page Sections
1 Commands
2 System calls
3 C library routines
4 Devices and networks
5 File formats
6 Games and demos
7 Miscellaneous
8 System administration.
Review Week Two Information
Types of File and Directory Access:
Access
r
File Meaning
View file contents
Directory Meaning
Search directory contents
w
Alter file contents
Alter directory contents
x
Run executable file
Make your current
directory
-rwx---------rwx---------rwx
Owner 700
Group 070
Other 007
Review Week Two Information
Shell and Programs Access:
To run a shell script, you will need read (r) and execute
(x) access. The read access mode is a binary 4. The
execute access mode is a binary 1.
To run a binary executable program, you will need
execute (x) access. The execute access mode is a
binary 1.
Week’s 2 & 3 Expected Outcomes
Upon successful completion of this module,
the student will be able to:
• Create scripts using shell/Perl variables
and program control flow.
• Use redirection and pipes to combine
scripts and executables.
• Use man page system and find script
tools.
• Discuss Perl Language
Next Lab Assignment
Introduction to Perl:
Perl - Practical Extraction and Report Language
Originally developed by Larry Wall, a linguist.
Perl is 21 years old and Perl 5 is 14 years old.
• Perl is a simple language
- Compiles and executes like a shell
script or a batch file
- Perl doesn’t impose special growth
limitations on arrays and data strings
- Perl is a composite of C, AWK, and
Basic
- Originally developed to process text and
automating tasks.
Next Lab Assignment
Perl’s range of flexibility
- System administration
- Web development
- Network programming
- GUI development
Major features
- Procedural Programming
Sequence or unstructured statements
Includes routines, subroutines,
methods, or functions
- Object Oriented Programming
Module uses “objects” and their
interactions to design applications and
computer programs.
Next Lab Assignment
Major features (continued)
- Powerful built-in support for text
processing
- Large collection of third-party
modules.
Next Lab Assignment
The Advanced Scripting lab assignment requires two
shell scripts to be written.
srch.sh
srchfile.sh
Demonstrate
Execution of srch.sh and srchfile.sh
Case #1: ./srch.sh <pattern> <file name / directory
name>
The srch.sh script will call the srchfile.sh script to
perform a specific task. The srchfile.sh searches for a
file with a pattern and outputs the matching
information to standard output. After all directory
entries have been read, control is returned to the main
script, srch.sh.
Break Out Problems
1. scalar@ARGV
2. $ARGV[0]
3. filter
4. unless
5. $NUMBER
6. exit 1
7. $ARGV[1]
8. %
(%directory)
9. $
($quote)
10. @ (@names)
11. diff
12. tr “[a-z]” “[A-Z]” < filein > fileout
Next Lab Assignment
Read your Programming Perl text book.
Chapter One (1)
Chapter Two (2)
Review Chapter 32: Standard Modules
Review Chapter 33: Diagnostic Output
Messages
Read Module Two listed under the course
Web site.
Upcoming Deadlines
• Lab Assignment 1-1, Obtain a Proctor for
Exams, due January 16, 2011.
• Lab Assignment 2-1, Simple Shell Scripting,
due January 23, 2011.
• Lab Assignment 3-1, Advanced Scripting, due
January 30, 2011.
• Lab Assignment 4-1, Simple Perl Exercise,
due February 6, 2011.
Lab Assistance, Questions and
Answers
Questions
Comments
Concerns
After class I will help students with their scripts.