CS 325 - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

CS 325

Description:

Make sure you have an 'normal, interactive shell' (ksh/bash) ... Lose line breaks entirely. CS 325 Summer 2004. Class Exercises (short) ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 23
Provided by: dyes
Category:
Tags: linebreaks

less

Transcript and Presenter's Notes

Title: CS 325


1
CS 325
  • Unix Programming Environment
  • and
  • Windows Programming
  • with Microsoft Foundation Classes (MFC)

2
Lecture 3
  • Today
  • Unix programming environment
  • make
  • ftp
  • chmod
  • Homework
  • Reading Assignments
  • Unix
  • vi, emacs, make, ftp
  • http//bama.ua.edu/cgi-bin/cgiwrap/unixinfo/chsh.
    pl
  • Make sure you have an normal, interactive shell
    (ksh/bash)
  • Sign up for an account on unix.eng.ua.edu
    (required)
  • For Fun http//www.catb.org/esr/writings/taoup/h
    tml/

3
Larger Makefiles
  • all a.out clean
  • CSTree.o CSTree.cpp CSTree.h
  • g -c CSTree.cpp
  • CSVector.o CSVector.cpp CSVector.h
  • g -c CSVector.cpp
  • CSContainer.o CSContainer.cpp CSContainer.h
  • g -c CSContainer.cpp
  • a.out CSTree.o CSVector.o CSList.o CSQueue.o
    CSStack.o CSContainer.o
  • g CSTree.o CSVector.o CSList.o
    CSQueue.o CSStack.o CSContainer.o
  • clean
  • rm .o

4
Useful Commands
  • Touch filename
  • make step
  • make tree.o
  • execute just the steps to build tree.o
  • make clean
  • Run the clean step
  • make f someOtherMakefile
  • Specify the makefile to use
  • Allows you to have more than one in a directory

5
Class Exercises
  • Just the basics of make
  • There are many more features
  • It's a language on its own
  • Non-template code from project1 is a multifile
    project. My source files for these can be found
    on bama at /st3/yessi001/inclass/ExampleMake
  • You can copy this directory via
  • cd
  • mkdir ExampleMake
  • cp /st3/yessi001/inclass/ExampleMake/
    /ExampleMake

6
Moving files to/from Unix
  • Cut and Paste
  • Right click on the menu bar of telnet window
  • Works as if keystrokes sent
  • Limited buffer size
  • May lose data
  • Ok for small files

7
Moving files to/from Unix
  • Moving files between a PC and Unix
  • Use ftp(file transfer protocol)
  • PC must be connected to the network
  • C\gtftp bama.ua.edu
  • Connected to bama.ua.edu.
  • 220-
  • 220- Use of this system (lines suppressed here)
  • 220 bama.ua.edu FTP server .
  • User (bama.ua.edu(none)) cordes
  • 331 Password required for cordes.
  • Password ltenter password heregt
  • 230 User cordes logged in.
  • ftpgt put hello.C
  • 200 PORT command successful.
  • 150 Opening ASCII mode data connection for
    hello.C.
  • 226 Transfer complete.
  • ftp 85 bytes sent in 0.00Seconds
    85000.00Kbytes/sec.
  • ftpgt quit

8
Moving files to/from Unix (cont)
  • Other ftp commands
  • dir, lists all the files on the remote system
  • cd xxx, changes directory on the remote
    system(also have lcd to change local directory)
  • get xxx, gets a file from the remote system
  • binary, toggles to binary mode (non-ASCII files)
  • mput .cpp, copies all your cpp files to remote
    sys(also have mget to retrieve files)
  • help, gives list of commands

9
Windows version
  • Most pcs have a windows version of ftp
  • Start
  • Programs
  • WS_FTP (usually)
  • WS_FPT
  • Beside host name/Address type bama.ua.edu
  • Enter your ID and password in appropriate spots
  • Click OK
  • This is a much easier way to ftp, however, be
    familiar with Unix version as well

10
Some Final Notes
  • Two modes of transport
  • binary
  • ascii
  • Binary
  • Copies bits exactly
  • Note that .exe compiled on windows won't run on
    bama still .exe's are examples of files that
    should be copied in binary mode
  • ascii
  • Twiddles line ending during transfer of text
    files
  • Some machines want \r\n
  • Some machines want \n only
  • Some machines may want \n\r (? Not sure about
    this)
  • Some machines do it another way entirely (no
    concept of \n)
  • Effects of extra missing characters
  • Appear as junk
  • Lose line breaks entirely

11
Class Exercises (short)
  • Find a C file on your local PC
  • Copy it to your account on bama.ua.edu
  • Copy a file from your bama account to your local
    PC

12
ftp with IE
  • Use your browser to ftp files
  • Quick and dirty ftp in windows
  • No control
  • Cannot control binary/ascii mode
  • Or I don't know how
  • ftp//user_at_ftpserver
  • ftp//yessi001_at_bama.ua.edu
  • Will prompt for password
  • ftp//userpassword_at_ftpserver

13
Unix File Permissions
  • Each file in Unix has three levels of security
  • What the user can do to it
  • What people in the users group can do to it
  • What everyone else can do with it
  • The ls command can display security
  • /fs/cordes ls -l
  • total 10
  • drwxr-xr-x 2 cordes facstaff 512 Aug 30 1050
    cs325
  • drwx------ 2 cordes facstaff 512 Aug 30 0510
    foo
  • -rw-r--r-- 1 cordes facstaff 81 Sep 3 0820
    hello.C
  • drwx------ 2 cordes facstaff 512 Aug 30 0937
    mail
  • drwxr-xr-x 2 cordes facstaff 024 Mar 21 1999
    networks
  • ls l shows files and directories and gives extra
    information such as permissions, userid, group,
    last modified date

14
Unix File Permissions (cont)
  • /fs/cordes ls -l
  • total 10
  • drwxr-xr-x 2 cordes facstaff 512 Aug 30 1050
    cs325
  • drwx------ 2 cordes facstaff 512 Aug 30 0510
    foo
  • -rw-r--r-- 1 cordes facstaff 81 Sep 3 0820
    hello.C
  • drwx------ 2 cordes facstaff 512 Aug 30 0937
    mail
  • drwxr-xr-x 2 cordes facstaff 024 Mar 21 1999
    networks

permissions user group last-mod-date filename
15
Unix File Permissions (cont)
  • -rw-r--r-- 1 cordes facstaff 81 Sep 3 0820
    hello.C
  • - r w r - - r - -
  • indicates this is a regular file, not a
    directory
  • r w indicates the user can read write this
    file
  • r indicates the group can read this file
  • r indicates that others can read this file

16
Changing Permissions
  • chmod ltpermissionsgt filename
  • Permissions consist of who /- what
  • Who is u (user), g (group), o (others)
  • What is r (read), w (write), x (execute)
  • gives permission
  • - takes permission
  • Examples
  • chmod u-w hello.C (user cannot write)
  • chmod gor hello.C (group others can read)
  • chmod ar hello.C (a is short for u, g, o)
  • man chmod talks about changing permissions in
    terms of octal numbers

17
Class Exercises
  • Type ls l in your home directory. Explain
    what permissions are set for each file.
  • The file .plan in your home directory can tell
    information about you (what you do). In order
    for others to read this file, they need to be
    able to execute your home directory (.) and also
    read your .plan file. Set it up so that other
    people can finger userid and see your .plan.

18
Unix requirements for 325
  • Basic manipulation of your files on Unix
  • Create sub-directories for organization, etc
  • Edit and compile C files
  • Use g and make
  • Move files between PCs and Unix
  • Using ftp, not only QD windows tricks

19
Unix Directories
  • mkdir
  • Creates directory
  • rmdir
  • Removes directory (must be empty)

20
Man pages
  • The unix man pages are online and on virtually
    every unix system
  • man entry eg man ls
  • Details
  • Options
  • Sometimes examples
  • More than you want to know
  • Sometimes tough to wade though
  • C stuff too library details etc
  • Note I didn't say C

21
Unix apropos
  • apropos keyword
  • Searches on keyword for relevant info
  • Useful when you cannot use man (looking for
    command)
  • Very limited last resort resource

22
Class Exercises
  • Teams new to Unix
  • Editors how do you
  • Copy a line
  • Delete a line
  • Give the command to
  • Rename hello.cpp to hello.C
  • Copy (to your home dir) hello.cpp from
    /st3/yessi001/cs325
  • Mail hello.cpp to yourself
  • Teams that know Unix
  • Give a one-line command (you can use pipes) to
  • Find the home directory of the user cordes
  • Print your last name in hex (and octal)
  • Print the first name of all the users on the
    system with the last name Smith
  • Convert the contents of hello.C to uppercase
Write a Comment
User Comments (0)
About PowerShow.com