Last Week in Review - PowerPoint PPT Presentation

1 / 88
About This Presentation
Title:

Last Week in Review

Description:

Certain codes can mess up the printer's settings) The print out will be found in ... A program is used to line up the print jobs in a line (print queue) to be printed ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 89
Provided by: Her96
Category:
Tags: last | mess | review | up | week

less

Transcript and Presenter's Notes

Title: Last Week in Review


1
This Presentation has been prepared by Ann Hersch
2
Review
  • Connecting to the system
  • Seneca - telnet - phobos
  • Home - connect ISP - telnet//phobos.senecac.on.ca
  • hyperterminal in directly to the Seneca server
  • UNIX commands
  • ls , ls -a, ls -l, ls -al (ls -a-l)
  • passwd,
  • pwd, cd, man
  • control keys s,q,d,c,z, h, u,r,w

3
Agenda
  • Additional Unix Commands
  • Purpose of nled editor - screen editor
  • Using nled editor
  • Accessing/Exiting nled
  • Using nled help
  • Common nled commands
  • Using vi editor - screen editor
  • Compiling a Program - purpose and procedure
  • Printing Source Code / Check Print Status
  • Using E-mail in phobos - Pine / Mail(Mail)

4
Unix Commands
  • Unix is the operating system (OS) for your PHOBOS
    account.
  • Your PHOBOS account is currently configured as a
    Command-Driven Interface which means that you
    need to perform tasks by typing in a Unix command
    and pressing the ENTER Key.
  • Therefore,some knowledge of Unix operating system
    commands are required

5
Unix Commands
  • Directory Navigation Administration
  • pwd Displays current directory
  • cd /tmp Changes to tmp directory
  • cd Changes to your default directory
  • cd .. Changes to parent directory
  • mkdir name Creates directory called name
  • rmdir name Removes directory called name
  • rm -r name Removes a directory called name
  • with all files contained in that directory

6
Additional Unix Commands
  • File Navigation Administration
  • cat filename (Displays file contents)
  • more filename (Displays contents
    screenful at a time)
  • cat filename more (Displays contents - large
    files)
  • rm filename (Deletes file)
  • cp sourcefile destinationfile (Copies file)
  • mv oldfilename newfilename (Moves or renames
    file)
  • Note The symbol (ltSHIFTgtlt\gt) is used to
    combine Unix commands (pipe command)

7
Additional Unix Commands
  • Miscellaneous
  • clear Clears screen
  • who Displays users on server
  • whoami Identifies users logged onto server
  • finger user Displays various information of user
  • man Online Unix reference manual
  • passwd Change user password

8
Directories
  • Relative Directory Address
  • Directories relative to other directories
  • eg. cd ../tmp would mean to move back to parent
    directory and then forward to the tmp directory
  • Absolute Directory Address
  • Full directory path
  • eg cd /home/ahersch/tmp which would mean
    starting from root switch to the home directory
    then to the ahersch subdirectory then to the tmp
    directory within ahersch.

9
Wildcards
  • A wildcard character is used to represent any
    character. Useful when searching for files where
    the full name is not known.
  • ls file? (list all files with 1 character
    after file)
  • ls file?? (list all files with 2
    characters after file)

10
Wildcards
  • The character ? will match any single character.
    The character will match any number of
    characters
  • For Example
  • ls file (list all files in the current directory
    beginning with file)

11
Redirection
  • REMEMBER UNIX views all files and directories /
    input / output as files so
  • stdin - standard in - keyboard
  • stdout - standard out - screen.
  • A method to redirect output from screen display
    to a file is called redirection by UNIX.
  • E.g.. ls -al gt longlistroot.txt
  • will get a long listing of all
    files/directories in the current directory and
    rather than showing you on the screen will create
    the file longlistroot.txt and place the
    information in this file. (if it exists, it will
    destroy any information previously in the file)

12
Redirect Output to a File
  • Redirect to file - use gt
  • e.g. who gt who.txt
  • Note that redirecting a file will overwrite
    information on file if saved under the same
    filename.
  • NOTE if you do not want to overwrite use gtgt
    to append the information to the given file. As
    finger ahersch gtgt who.txt will add the finger
    information to the bottom of the who.txt file.

13
Pipe - FYI
  • A another useful feature of UNIX is its ability
    to combine one or more Unix commands
  • e.g..
  • ls -al more
  • This displays full listing of files, but pauses
    when screen becomes full.
  • This is a simplistic example and is for your
    information only. Pipe command is one of the most
    powerful features of UNIX.

14
Removing Directories
  • Removing directories is reverse order of building
    directories
  • Cannot remove directories containing files or
    other subdirectories
  • Need to step-back to at least parent directory
    to remove empty directory
  • Issue command rmdir

15
Directory / File Permissions
  • Because you share your account space on the
    PHOBOS server with other users, there is a
    concern that other users can modify or delete you
    directories or files in your account!
  • When you create a webpage on the COLUMBUS server,
    you should be aware of the same concerns!

16
File Permissions
17
Directory / File Permissions
  • There are 3 types of users that may be able to
    read / modify /execute your directories and files
  • Yourself (User)
  • Other users on your server (Group users)
  • Any Other User (i.e. Users viewing your webpage
    via their own Internet Service Provider)

18
Directory / File Permissions
  • Directory
  • d r w x r w x r w x
  • File
  • - r w x r w x r w x

User Group Other
User Group Other
19
Chmod Command
  • A Unix command to change the way in which a file
    (or directory) can be accessed by the owners of a
    file, the group to which the file belongs, and/or
    all other users

20
File Permissions Commands
  • chmod
  • u owner of the file
  • g group to which owner belongs
  • o all other users
  • a all users

21
File Permissions Commands
  • chmod
  • add permission
  • - remove permission
  • set permission
  • e.g.. Chmod uw,grw,or /home/ahersch/lab2

22
  • Purpose of a Text Editor
  • Editors
  • Line
  • Screen
  • In order to write programs, you need a text
    editor that can create a file. A text editor is
    also used to modify, print and save a file.
  • NLED - Neat Little Editor written by one of
    Senecas Computer Studies Faculty members.
  • vi - standard text editor available with Unix

23
Editors
  • There are two types of editors and two interfaces
  • Line and Screen Editors
  • Text and GUI interfaces

24
Editors
  • Ed and EDIT are LINE TEXT editors
  • NLED, VI and EMACS are SCREEN TEXT editors
  • WORD PERFECT, MS WORD, and WORD PRO are SCREEN
    GUI editors.

25
Note
  • nled is covered in our class notes
  • emac and vi are covered in many UNIX books.
  • emacs and vi are covered in UNIX SYSTEM V, Mark
    Sobell
  • ed, emacs and vi are covered in UNIX for DUMMIES,
    Levine and Young

26
Editors
  • Line editors are easy to use, but limited in
    scope
  • Screen editors are more complex, and more
    powerful.

27
Editors
  • Most people who program become VERY GOOD at one
    editor, usually a screen editor, and use that one
    editor all the time
  • Some people prefer the ease of a line editor, so
    they become VERY GOOD at one line editor, and
    competent with one screen editor

28
Line Editors
  • Line editors are easy to use, but limited in
    scope
  • few commands
  • can only edit one line at a time
  • limited cut and paste

29
Screen Editors
  • Screen editors are more complex, and more
    powerful.
  • Edits a full screen (24 lines) or more
  • Many commands
  • can cut and paste

30
Editors - Modes
  • Editors (both line and screen) have two modes
  • Insert Mode
  • Command Mode

31
Editors - What Mode am I in?
32
Editors - Insert Mode
  • The mode which allows you to add text to your
    document
  • usually, what you type becomes part of the
    document

33
Editors Enter Insert Mode
  • ED a or i
  • EDIT a or i
  • nled esc
  • emacs just type
  • vi a or i, A or I

34
Editors - Command Mode
  • The mode which allows you to perform tasks with
    your document such as add, delete, save.

35
EditorsEnter Command Mode
  • ed
  • edit
  • nled
  • emacs
  • vi
  • return on blank line
  • period alone on line
  • esc
  • uses control key for all commands
  • esc

36
EditorsHelp Commands
  • Ed none?
  • edit none?
  • nled ?
  • vi none?
  • emacs ? Or H

37
Creating a (Source) file - using nled
  • Logon to PHOBOS via telnet
  • At the Unix prompt type
  • nled file.name ltENTERgt

38
Nled Text Editor
  • There are 2 major modes or states for the
    Nled Editor
  • Input Mode (creating / moving / editing)
  • Command Mode
  • (execute commands - Help, Save, Print, etc)

39
Nled Text Editor
  • Movement
  • ltCTRLgtltdgt Move down one screenful
  • ltCTRLgtltugt Move up one screenful
  • ltCTRLgtltbgt Move to beginning of line
  • ltCTRLgtltegt Move to end of line
  • ltCTRLgtlttgt Move to top of file
  • ltCTRLgtltrgt Move to bottom of file

40
The Nled Text Editor
  • Common nled Commands
  • ltESCgtlt?gt Displays help menu
  • ltESCgtltbgt Mark beginning of block
  • ltESCgtltegt Mark end of block
  • ltESCgtltsgt Save file continue editing
  • ltESCgtltxgt Save file exit
  • ltESCgtltqgt Abandon recent edit exit

41
vi Editor - Basics
  • vi editor like nled is a text editor available
    to students to assist in creating source files
    for programs in the UNIX environment.
  • obscure and tedious initially to learn.
  • positives include available on most UNIX systems.
  • NOTE to use the vi editor your .profile must be
    changed so that the shell can locate the command.
  • Add following lines set -o vi

    EDITOR/usr/bin/vi
    export
    EDITOR

42
vi editor
  • There are 2 major modes or states of
    operation for the vi Editor
  • Input Mode (insert / append / enter mode)
  • Command Mode (delete characters, lines, movement
    / saving text / exiting).

43
vi editor - basics
  • MOVEMENT (command mode)
  • h move left one character
  • j move down one line
  • k move up one line
  • l move right one character
  • 0 move to beginning of current line
  • move to the end of the current line
  • b move up one screenful
  • f move down one screenful
  • G go to last line of file
  • 5G go to line 5 of the file.

44
vi editor - basics
  • Deletion (command mode)
  • x delete single character
  • dd delete current line
  • Save text / Exit (command mode)
  • w save the text with the original file name and
    continue editing
  • wq save text with the original file name and
    exit
  • q! Quit without saving any of the current
    changes.

45
vi editor - basics
  • Entering into Input mode
  • i input characters at the current cursor
    position
  • I input characters at the beginning of the line
  • a input characters to the right of the current
    cursor position
  • A input characters at the end of the current
    line
  • o input characters on a new line below the
    current line
  • O input characters on a new line above the
    current line.
  • NOTE Press the escape key to leave the input
    mode (return to command mode).

46
Compilers
47
Compilers
  • GAP between
  • how people think and how they solve problems
  • How computers are designed to solve problems

Selections from Fundamentals of Compilers by
Karen A. Lemone
48
Compilers
  • A compiler is a special translator which takes a
    high level language, such as Pascal or C, and
    translates it to a low level representation which
    the computer can ultimately execute

Selections from Fundamentals of Compilers by
Karen A. Lemone, page 2
49
Compilers
  • There are several compiler phases
  • Lexical analysis (scanning)
  • Syntactical analysis (parsing)
  • Semantic Analysis
  • Optimization
  • Preparation for code generation
  • Code Generation

Selections from Fundamentals of Compilers by
Karen A. Lemone
50
Compilers
  • TOKENS
  • A token is a lexical unit. For example
  • Keyword IF or PRINTF
  • A constant 3 or 133
  • Identifiers X or Name
  • operators , , or
  • Punctuation ( or

Selections from Fundamentals of Compilers by
Karen A. Lemone
51
Compilers
  • Lexical analysis (scanning)
  • Separates and groups characters into tokens. For
    example
  • X Y 12
  • would become
  • X,,Y,,12
  • for five tokens

Selections from Fundamentals of Compilers by
Karen A. Lemone
52
Compilers
  • Syntactical analysis (parsing)
  • Groups tokens into structures, for example
  • X Y 1
  • would be grouped as an assignment statement.

Selections from Fundamentals of Compilers by
Karen A. Lemone
53
Compilers
  • Semantic Analysis
  • Determines the meaning of phrases. For example
  • X Y 12
  • Does X and Y have a meaning?
  • Can 12 be added to Y?
  • Can this vale be assigned to X?

Selections from Fundamentals of Compilers by
Karen A. Lemone
54
Compilers
  • Optimization
  • Just what is says .. Can the code be run easier
    and/or faster

Selections from Fundamentals of Compilers by
Karen A. Lemone
55
Compilers
  • Preparation for code generation
  • What memory will be allocated
  • Which registers will be used

Selections from Fundamentals of Compilers by
Karen A. Lemone
56
Compilers
  • Code Generation
  • Generates ASSEMBLY / MACHINE language code for
    your program.

Selections from Fundamentals of Compilers by
Karen A. Lemone
57
Compilers
  • Example of Assembly code
  • PushAddr X
  • PushAddr Y
  • Load (S) R1
  • Load R2 12
  • Add R2 R1
  • Store R1 (S)

Selections from Fundamentals of Compilers by
Karen A. Lemone
58
Compilers
  • PushAddr X Find address for X, push
  • PushAddr Y Find address for Y, push
  • Load (S) R1 Load value of Y into R1
  • Load R2 12 Load number 12 into R2
  • Add R2 R1 Add R1 to R2, place in R2
  • Store R1 (S) Store value in R2 in X

Selections from Fundamentals of Compilers by
Karen A. Lemone
59
Compiling a Program
Edited File / Source Code
ExecutableFile
Compiler
hello.c
a.out
cc hello.c
60
Compiling a Program
  • Although there is more than one Unix command that
    may be used to compile a program, we will show
    you the cc Unix command. (C language compiler)
  • There are two different options of using the cc
    compiling command. One options creates an
    executable file called a.out, the other option
    allows the user to name the executable file.

61
Compilers
  • In UNIX, to compile a c program, you enter
  • cc hello.c
  • This creates an object module (hello.obj) which
    is then link/loaded with other system library
    programs to produce an executable file (also
    known as the Load module)(a.out). If errors arise
    you will receive some diagnostic messages.

Selections from Fundamentals of Compilers by
Karen A. Lemone
62
Compilers
  • See page 421 of the Capron textbook for a
    detailed description of the compiling
    process

63
Compilers
  • If you add a flag, -o the executable file will
    be renamed the new file name, e.g.
  • cc hello.c -o hello
  • this will create an executable file called
    hello (In some cases you will have to change
    the permissions allowing for execution (x) in
    order to run the file)

Selections from Fundamentals of Compilers by
Karen A. Lemone
64
Printing Source Code
  • At times you will require printouts of your C
    programming code here at Seneca.
  • To print your source code contained in a files
    say hello.c, type the following command at
    the prompt
  • lpr hello.c ltENTERgt
  • (NOTE Never send executable files or files that
    have been compiled to the printer!!! Certain
    codes can mess up the printers settings) The
    print out will be found in room 2115 (?)

65
Check Printing Status
  • Printouts are placed in order by a first-come,
    first printed out basis.
  • A program is used to line up the print jobs in a
    line (print queue) to be printed
  • If you want to see how many print-jobs are ahead
    of your own, you can check the status of your
    print-job by typing the following command at the
    Unix prompt
  • lpstat ltENTERgt (press ltCTRLgtltCgt to exit)

66
E-mail Protocols - Some background
  • A protocol is a set of rules that allow
    computers to communicate with one another
  • Some Protocols
  • TCP/IP (Transmission Control Protocol /
    Internet Protocol)
  • PPP (Point-to-Point Protocol)
  • SMTP (Simple Mail Transfer Protocol)

67
Simple Mail Transfer Protocol (SMTP)
  • A TCP/IP connection allows users to send e-mail
    messages by standard addresses to anyone around
    the world connected to the Internet
  • The set of rules to allow this to happen is the
    Simple Mail Transfer Protocol (SMTP)

ISP
ISP
TCP/IPSMTP
68
Receiving E-mail Messages
  • It is important to note that e-mail messages are
    NOT sent directly to the terminals (PCs), but are
    sent to the mail servers that look after e-mail
    administration

69
Receiving E-mail Messages
  • The user must download the received e-mail
    messages from the mail server to view those
    e-mail messages.
  • The ISP may dictate, or the user must select,
    another set of mail protocols to indicate how the
    user will accept the received e-mail messages
    (POP, IMAP)

70
POP vs IMAP Protocols
  • POP (Post-Office Protocol)
  • Received e-mail messages that are downloaded to
    your PC are removed from mail server
  • IMAP (Internet Message Access Protocol)
  • Received e-mail messages that are downloaded to
    your PC are not removed from mail server.

71
POP vs IMAP
  • Implications
  • If you have a POP e-mail account, you can
    download your e-mail message on one PC, but
    cannot go to another PC and view previously
    viewed or downloaded e-mail messages(they have
    been removed from mail server!)
  • If you have an IMAP e-mail account, you can
    download your messages (new or previously viewed)
    on any PC. You have control to move or remove
    previously viewed e-mail messages

72
Creating folders for mail messages
  • Most E-mail applications allow users to create
    folders or directories to better organize their
    e-mail messages

OPS124
Instructors Reply
General Questions
Etc...
73
Using E-mail in PHOBOS
  • There are two main e-mail software programs on
    Phobos
  • Pine (available on select UNIX systems)
  • mail or mailx (a general UNIX utility
    program)
  • Common e-mail Operations
  • Send Message
  • Receive / Reply to / Forward Messages
  • How to Forward PHOBOS e-mail to your home
    account.

74
Launching Pine Program
75
Main Menu
The user can select menu items by using arrow
keys or press the first letter in the menu item.
76
Send Message
Select COMPOSE MESSAGE from the main menu, then
enter the e-mail address(s), subject and body of
message.
Press ltCTRL xgt to send
77
Receive Message
Select FOLDER LIST from the main menu, then
select INBOX from the sub menu. You can move and
select e-mail messages to read.
78
Receive Message
79
Receive Message
80
Reply to / Forward Message
While reading messages, refer to the status bar
at the bottom of the screen for keys to reply to
/ Forward e-mail messages.
81
Send an Attached File with E-Mail Message
  • You can send files as an attachment to your
    e-mail message. For example, you could send a
    resume saved as a MS-Word document to a
    prospective employer.

82
Send an Attached File with E-Mail Message
  • Steps
  • Logon to PHOBOS
  • At the Unix prompt, type pine
  • Select Compose Message (type in users e-mail
    address)
  • Press ENTER until cursor is to the right of
    Attchmnt
  • Press ltCTRLgtltJgt, then ltCTRLgtltTgt

83
Send an Attached File with E-Mail Message
  • Move cursor to highlight appropriate file and
    press ENTER
  • You may type a short description of the
    attachment (optional) press ENTER
  • Repeat procedure to attach other files, and when
    finished, press ltCTRLgtltXgt to send to user

84
Pine
  • How to Receive Attachments
  • Read E-mail message
  • Press V to view attachments
  • Select attachment file
  • Press S to save file
  • File will be saved on your home directory

85
Exit Pine
Return to the main menu (in some cases by
pressing the letter m ) then select QUIT
86
Forwarding E-Mail
  • You can redirect e-mail messages in your Phobos
    account to your home e-mail address
  • Procedure
  • Logon to Phobos
  • Use text editor (nled) to create a file in your
    home directory called .forward
  • on first line type your e-mail address
  • save exit text editor

87
Using the UNIX mailx / mail Programs
  • Details will be covered in Lab2 next week.

88
For next week
  • Read
  • Capron - Chapter 14 - Programming basics
  • Programming in C - Section 3 of the OPS124 NOTES
  • Complete Assignment 1 to be handed in beginning
    of class next week.
  • Practice Do Exercise 1 - Lab1a
  • UNIX commands
Write a Comment
User Comments (0)
About PowerShow.com