CS 141 Homework Assignment #18


In class graded exercise   
   Most students finished this exercise in class #13 on 5/09/07.

Shutdown windows
 and boot from the Knoppix 5.1.1 cd.

start a web browser (konquerer or ice weasel)
 unix01.sac.edu
  make sure you access our class web site
   By default, knoppix sets up the network to be dhcp

press ctrl alt F1   (to a char based screen)
 press enter
  cal

press ctrl alt F2
 ls
 /bin/ls

press ctrl alt F1

how to return to the gui
 ctrl alt F5

press Ctrl alt F2

ftp unix01.sac.edu
   name:    your 3 char login
   password:   your 5 char password

    cd /classes/s2007spr/data     # change cur remote dir
    ls
    get knoppix-progs             # from remote to cur dir
    quit

    # here are some other useful ftp commands
    # lcd xxx    # change cur local dir
    # put xxx    # put file from local to remote dir 
    # mget acme*
    # mput acme*
    # !cmd       # run this cmd on local system
    # !ls
    # binary     # transfer in raw mode, no fiddling
    # ascii      # will add CR to LF at EOL if unix to windows
                 # and remove CR at EOL if windows to unix

    background
       in vi,
       you can set up to 26 marks to remember a line 
        using the m cmd
         ma    (set the first mark)
         mb    (set the 2nd mark)
         mz    (set the last mark)
         'a    go to mark a
         'b    go to mark b
      ----
       there are 26 named buffers
        where you can save lines of text
            15yy     yank 15 lines into the unnamed buffer 
                      starting from the cur line
            p        will paste the unnamed buffer
                      after the cur line
            "a15yy   yank 15 lines into named buffer a
            "ap      paste buffer a
            "bp      paste buffer b

vi knoppix-progs
move your cursor to line #2   which is the start of the first program
ma
move your cursor to the end of the program tst.c (line 12)
"ay'a
:e tst.c
"ap
:wq
cat tst.c

     # background
     # :e #   to go back to the first file

make tst    # will compile this source tst.c to a c program called tst
            # or cc -o myprog tst.c
./tst       # should show Hello world 10 times

create tst.exp
by yanking those lines from knoppix-progs
    Make sure your magic first line is the first line of the file
chmod +x tst.exp
./tst.exp

next extract and run all the rest of the programs
in knoppix-progs
 All the script programs need chmod and ./scriptname
  The C program and java both create (step on) tst
   as a runable object.

When you are done,
 you should have extracted and run these 6 types of programs:
1. C program
2. expect script
3. perl script
4. python script
5. shell script
6. java program

to get credit for this homework:
show the instructor the following
1. 
   pg tst.*[!s] | less
2. 
   run one program as requested by the instructor


Here is the knoppix-progs
to student: save following as tst.c #include <stdio.h> /*tst.c is a c application *make tst *./tst */ main() { int ii; for (ii=1;ii<=10;ii++) { printf("Hello world\n"); } } to student: save following as tst.exp #!/usr/bin/expect -f #tst.exp is an expect script (no compile step) for {set ii 1} {$ii<=10} {incr ii 1} { send "Hello world\n" } to student: save following as tst.pl #!/usr/bin/perl #tst.pl is a perl script (no compile step) for ($ii=1;$ii<=10;$ii++) { print "Hello world\n"; } to student: save following as tst.py #!/usr/bin/python #tst.py is a python script (no compile step) for count in range(10): print 'Hello world' to student: save following as tst.sh #!/bin/sh #tst.sh is a bourne/korn/bash shell script (no compile step) CNT=1 while [ $CNT -le 10 ] do echo "Hello world" CNT=`expr $CNT + 1` done to student: save following as tst.java /*tst.java is a java application * javac tst.java # compile to create tst.class and runnable tst * java tst */ public class tst { public static void main(String[] args) { int ii; for (ii=1;ii<=10;ii++) { System.out.println("hello world"); } } }