AHS-TechClub-021913 - Avon High School Tech Crew

advertisement
V2012.13
Agenda
• Old Business
– Delete Files
• New Business
– Week 12 Topics:
• Coming up:
– Hyland Field Trip: Feb 21st
• Tiny Circuits/Arduino Review/Demo
• Linux Intro (continued)
– Scripts/scripting
Avon High School Tech Crew
2
Future Meeting Preview
GAMING
OPERATING
SYSTEM
NETWORK
CLOUD
PERIPHERALS
STORAGE
I/O
CPU
NETWORK
DATA &
DATABASES
GRAPHICS
MEMORY
GRAPHICS
LANGUAGES
VIRTUAL
Avon High School Tech Crew
APP
DEVELOPMENT
3
New Business
• Tiny Circuits/Arduino Review/Demo
– Getting Started w/ Arduino
– Simple Demos
• Intro to Linux
– Scripts/scripting
– Example
Avon High School Tech Crew
4
Basic Commands
• Commands take the following form:
<Command> <Switches> <Parameters> <Target>
• Switches: single letters, preceded by a hyphen,
that adjust what the command does
• Parameters: things that the command needs to
know in order to work
• Target: the thing (such as a file) that the
command will be applied
Avon High School Tech Crew
5
Basic Commands - grep
• grep
Avon High School Tech Crew
6
Create Your First Script
• Open a text editor
– Menu->Accessories->gedit
• Scripts always begin with:
#! /bin/bash
• Save your script (date.sh)
• Make the script executable
$ chmod +x date.sh
• Run your script
$ ./date.sh
Avon High School Tech Crew
7
Create Your First Script
• Output
$ ./date.sh
Fri Mar 8 13:27:05 EST 2013
Avon High School Tech Crew
8
Create Your First Script
• Your Challenge:
– Let’s add some features
• Display only the date
• Display the Day
Avon High School Tech Crew
9
Create Your First Script
Avon High School Tech Crew
10
Create Your First Script (date.sh)
• Output
$ ./date.sh
Today's date is: March 8
The day of the week is: Friday
The year is: 2013
The complete date is: Friday, March 8, 2013
Avon High School Tech Crew
11
Create Your First Script (date.sh)
#!/bin/sh
echo -n "Today's date is: "; date +"%B %-d"
echo -n "The day of the week is: "; date +"%A"
echo -n "The year is: "; date +"%Y"
echo -n "The complete date is: "; date +"%A, %B %-d, %Y"
Avon High School Tech Crew
12
Script to Display Memory (mem.sh)
#! /bin/bash
# Total memory space details
echo "Memory Space Details"
free -t -m | grep "Total" | awk '{ print "Total Memory space : "$2 " MB";
print "Used Memory Space : "$3" MB";
print "Free Memory : "$4" MB";
}'
echo "Swap memory Details"
free -t -m | grep "Swap" | awk '{ print "Total Swap space : "$2 " MB";
print "Used Swap Space : "$3" MB";
print "Free Swap : "$4" MB";
Avon High School Tech Crew
13
Download