Week Five Agenda
•Link of the week
•Review week four lab assignment
•This week’s expected outcomes
•Next lab assignment
•Break-out problems
•Upcoming deadlines
•Questions and answers
Link of the week
Data Disaster
• http://www.ontrackdatarecovery
• http://hp.com.au/setlTfree/connect
Data Disaster
- Use dedicated circuits for your connection
- Keep your computer cool and in a dry place
- Use a UPS (Uninterrupted Power Supply)
- Don’t assume that your data is permanently
destroyed
Link of the week
Data Disaster
- Big and small company operations
- Backup services
- Trouble shooting
- Data recovery
Define: Power Monkey
Define: Thermal Logic Technology
Review week four lab assignment
• Shell Commands
cat
chmod
cp
date
find
grep
mkdir
more
less
rmdir
rm
sort
sleep
wc
kill
diff
cd
whence
umask
Review week four lab assignment
•
•
Shell Arithmetic expressions
<=
- less than or equal tp
>=
- greater than or equal to
<
- less than
>
- greater than
==
- equal to
!=
- not equal to
*
- multiplication
/
- division
+
- addition
- subtraction
Shell statements
printf “string”
- output a string of information
echo $COUNTER
- output content of the variable COUNTER
printf $NUMBER
- output content of the variable NUMBER
NUMBER=$(($NUMBER-1))
- decrease NUMBER value by one
$#
- number of positional parameters
$?
- return value
$$
- prosess id of this shell
$!
- bachground process id
Review week four lab assignment
• Shell Conditional Expression Primitives
-r
- true if file exists and is readable
-w - true if file exists and is writable
-x - true if file exists and is executable
-f
- true if file exists and is a file
-d - true if file exists and is a directory
-eq - true if value of exp1 and exp2 are equal
-ne - true if value of exp1 and exp2 are not equal
-gt - true if value of exp1 is greater than value of exp2
-ge - true if value of exp1 is greater than or equal to value of exp2
-lt - true if value of exp1 is less than value of exp2
-le - true if value of exp1 less than or equal to value of exp2
• Shell Quoting
‘ …’ - single literal quotes
“…” - double quotes (interpolation allowed)
`…` - single back ticks (command execution)
Review week four lab assignment
•
•
Shell I/O Redirection
< variable
> variable
variable >> variable
Shell Syntax
while [ … ]
do
…
done
if [ … ]
then
…
fi
if [ … ]
then
…
elif
…
fi
test –r “$test_file”
test x+1 –gt y
- read from file (cat < test_file)
- write to a file (cat > test_file)
- append content of file_1 to the end of file_2 (cat file_1 >> file_2)
Review week four lab assignment
•
•
Perl Binary Arithmetic Operators
+
- addition ($a + $b)
*
- multiplication ($a * $b)
%
- modulus (remainder of $a divided by $b)
**
- exponentiation ($a raised to the power of $b)
Perl Comparison Operators
==
- equal
!=
- not equal
<
- less than
>
- greater than
<=
- less than or equal
>=
- greater than or equal
- comparison (0 if equal, 1 if $variable_1 greater, -1 if
$variable_2 greater
Review week four lab assignment
•
•
Perl Comparison Operators
eq
- equal
ne
- not equal
lt
- less than
gt
- greater than
le
- less than or equal
ge
- greater than or equal
cmp
- comparison (0 if equal, 1 if $variable_1 greater, -1 if
$variable_2 greater
Perl Conditional Expression Primitives
-e $var
- true if file $var exists
-r $var
- true if file $var is readable
-w $var
- true if file $var is writable
-d $var
- true if $var is a directory
-f $var
- true if file $var is a file
-T $var
- true if file $var is a text file
Review week four lab assignment
•
Perl Quotes
“
‘
`
•
“ double-quotes
‘ single-quotes
` backtick-quotes
Perl String Operators
$arrayexp[0]=“string assignment”; (string assignment to zero
element of array)
$cmdexp=`ls –l`; (string output from a command)
$charexp=‘b’;
(string character assignment)
$strexp=“string assignment”; (string assignment)
$intexp=150;
(an integer)
$str_int=“I have two $pets”; (string with interpolation)
•
Perl Commands
chop
unless
print $var
pop
Review week four lab assignment
• Perl Variable Syntax
$
singular variables prefix (single value,
number or
string)
@
prefix for plural variable (array)
%
prefix for plural variable (hash)
$_
default variable
• Relational Operators
• Equality Operators
Review week four lab assignment
• Perl Syntax
while ( … )
{
…
}
If ( …)
{
…
}
If ( … )
{
…
}
else
{
…
}
Review week four lab assignment
• Perl Syntax
;
,
\n
end of statement delimiter
comma for line continuation
new line
Weeks four and five expected
outcomes
• Write Perl scripts, including variables,
control flow, and regular expression syntax
Next lab assignment
Programming Perl, Chapter 32 Standard Modules
Define: Module
Parsing the command line with Getopt::Std
Example:
listdir –l –n –a 10:00 bottom top
Perl utilizes @ARGV to capture the command line
arguments
Example: $ARGV[0]
‘-l’
$ARGV[1]
‘-n’
$ARGV[2]
‘-a’
$ARGV[3]
’10:00’
$ARGV[4]
‘bottom’
$ARGV[5]
‘top’
Next lab assignment
• Perl Array
@garage = (“rake”, “mower”, “shovel”);
($rake, $mower, $shovel) = @garage
• Perl Hash
%colormap=(
“12” => “gray”,
“19” => “black”,
“30” => “red”,);
%colormap = (“12”, “gray”, “19”, “black”, “30”, “red”);
Break-out problems
•
•
•
•
•
•
•
•
•
•
Global variable
Boolean
Binary
Executable file
Execute bit
fork command
Portable
Object file
System call
Data structure
Upcoming deadlines
•
•
•
•
Simple Perl Script, 5-1 is due 6/1/08.
Makefile Exercise, 7-2 is due 6/15/08.
Mid-term exam dates 6/9/08 through 6/14/08.
Programming Assignment 1, 6-1 is due 6/22/08.
- Script logic for the above assignment will be emailed
at the end of the week.
• Reading Assignment
Essential System Administration
Chapter One, pages 1 -8, 12 – 28
Chapter Two, pages 32 – 61
Chapter Three
Programming Perl
Chapter One
Chapter Two, pages 47 – 65, 69 – 73, 76 - 83
Chapter Three, pages 86 – 90, 92 -101
Chapter Thirty Two, pages 865 – 867, 899
Questions and answers
• Questions
• Comments
• Concerns
• After class I will help students with their
scripts.
© Copyright 2026 Paperzz