|
Second Summer 2003 |
Wed Aug 13If you're taking the Take Home version you don't need to come.
Tue Aug 12(With his permission. You can start from it for the Final).
Here's a link to Andy Everett's Project Script.
(Again with his permission. Includes extra files).
Here's the link to the Javascript exercises for the final).
Mon Aug 11
Here's the script ready for final appointments.
If you need to upload binary files with PHP.
Some help with the Lindley portfolio:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class One extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException,
IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String one, two;
String what = req.getParameter("picture");
if (what == null) {
what = "";
}
if (what.equals("one")) { one = "One"; } else {
one = "<a href=\"/examples/servlet/One?picture=one\">One</a>";
}
if (what.equals("two")) { two = "Two"; } else {
two = "<a href=\"/examples/servlet/One?picture=two\">Two</a>";
}
out.println("<html><head><title>Mamma mia!</title></head><body bgcolor=\"white\">" +
"<table border><tr><td>" +
one +
"</td><td>" +
two +
"</td><td>Three</td><td>Four</td></tr>" +
"<tr><td colspan=4 align=center>Picture</td></tr>" +
"<tr><td colspan=4 align=center>Caption</td></tr>" +
"</table></body></html>");
}
} // thanks to Pavel Anashenko for noticing this curly brace was missing
Here now is the starting point for the calculator.
<html><head><title>My calculator</title></head><body>
<% Integer a = (Integer)session.getAttribute("acc");
if (a == null) { a = new Integer(0); }
String argument = request.getParameter("arg");
if (argument == null) { argument = "0"; }
int conv;
try {
conv = Integer.parseInt(argument);
} catch(Exception e) { conv = 0; }
a = new Integer(a.intValue() + conv);
session.setAttribute("acc", a);
%>
<form>
The accumulator is now: <%= a %> <p> <input type="text" name="arg"> <p> </form>
</body></html>
Sun Aug 10Also, here's a note from Spring 2003.
From Jocelyn Bauer who was working on her project at the time:
Date: Mon, 28 Apr 2003 22:16:24 -0500 (EST)
From: Jocelyn Bauer <jobauer@cs.indiana.edu>
To: Adrian German <dgerman@cs.indiana.edu>
Subject: Perl LWP
Thanks for your help this morning. I have just been messing around with
the Perl LWP for a little bit and have gotten it to do what I wanted. I'm
able to call my servlet from my cgi script and have the servlet write to a
file. I'll have to work on having the servlet write to the database now.
Thanks again.
- Jocelyn
Date: Mon, 28 Apr 2003 22:20:20 -0500 (EST)
From: Jocelyn Bauer <jobauer@cs.indiana.edu>
To: Adrian German <dgerman@cs.indiana.edu>
Subject: Somemore
By the way, here is what I did in case others have the same questions:
I couldn't get it to work with the plain get method from the LWP::Simple
probably because my servlet took post requests.
use LWP 5.64;
use CGI;
my $other = 'http://burrowww.cs.indiana.edu:11836/stupendous/servlet/StockData';
$name = $query->param('uname');
$pass = $query->param('pword');
my $browser = LWP::UserAgent->new;
my $response = $browser->post( $other,
[ 'uname' => $name,
'pword' => $pass
]
);
Thanks a lot for both notes and congratulations!
Sat Aug 9
Place the file into htdocs and connect from the web.
Fri Aug 8
setenv CLASSPATH $CATALINA_HOME/common/lib/xerces.jar:$CLASSPATH
Thu Aug 7
<% int count, right; String message = "Hello and welcome to the addition quiz!";
if (session.getAttribute("count") == null || request.getParameter("reset") != null) {
session.setAttribute("count", new Integer(0)); count = 0;
session.setAttribute("right", new Integer(0)); right = 0;
} else {
count = ((Integer)(session.getAttribute("count"))).intValue();
right = ((Integer)(session.getAttribute("right"))).intValue();
try {
if (Integer.parseInt(request.getParameter("answer")) == ((Integer)(session.getAttribute("answerKey"))).intValue())
right += 1;
else
right += 0;
} catch (Exception e) { }
count += 1;
message = right + " out of " + count;
if (count == 10) {
message = "Final result: " + message + ". New game started "; count = 0; right = 0;
} else
message = "Your performance thus far: " + message;
session.setAttribute("count", new Integer(count));
session.setAttribute("right", new Integer(right));
}
int one = (int) (Math.random() * 100 - 50),
two = (int) (Math.random() * 100 - 50);
session.setAttribute("answerKey", new Integer(one + two));
%>
<html>
<body>
<form action="<%=request.getContextPath() + request.getServletPath()%>">
<%=message%> <p> Question <%=count+1%>. <%=one%> + <%=two%> = <input type="text" name="answer"> <p> <input type="submit" value="Proceed"> <input type="submit" name="reset" value="Reset"> <p> </form>
</body>
</html>
It is clean and compact, and a pleasure to study (I hope). (The long lines, you ask? I am really happy it's so easy to use them on the web.)
Wed Aug 6
Tue Aug 5Here's a diagram from some time ago.<?
$acc = 0 + $acc + $arg;
?>
<html>
<body>
<table><tr><td> <a href="<?=$SCRIPT_NAME?>?arg=1&acc=<?=$acc?>">Add One</a>
<td> <a href="<?=$SCRIPT_NAME?>?arg=-1&acc=<?=$acc?>">SubOne</a>
<tr><td align=center colspan=2> <font size=+6><?=$acc?></font>
</table>
</body>
</html>
Can you build a similar one describing your Tomcat?
Mon Aug 4We'll see each other on Thu for sure, though.
Meanwhile the lab assignment was the chat application.
And remember to get as much help from Barry as possible.
Also, stamping should be better done with TIME-stamps.
(And changing the mechanism by which we accept or reject a transaction).
Fri-Sun Aug 1-3
<html><head><title>Conditional output</title></head><body bgcolor="white">
<? if ($arg % 2 == 0) { ?> Even <? } else { ?> Odd <? } ?>
<form>
Type a number: <input type="text" name="arg"> <p>
</form></body></html>
Here's the basic idea behind stamped transactions:
<? session_start();
if (session_is_registered("alpha")) { } else {
session_register("alpha"); $alpha = 0;
}
if (session_is_registered("stamp")) { } else {
session_register("stamp");
}
if ($stamp == $stampCopy) {
$stamp += 1;
if ($fun == "add") {
$alpha = $arg + $alpha;
}
} else {
echo "Sorry!<hr>";
}
?>
<html>
<head><title>Calculator</title></head>
<body bgcolor=white>
<form>
Your balance currently is: <?=$alpha+0?> <p> Argument: <input type="text" name="arg"> <p> Function: <select name="fun">
<option value="non"> click me!
<option value="add"> deposit
<option value="sub"> withdraw
</select> <p> <input type="hidden" name="stampCopy" value="<?=$stamp?>">
When done push <input type="submit" value="Proceed"> </form>
</body>
</html>
Notice that this now carefully matches the EXACT behaviour of this second
one. This in spite of using server side sessions to keep state.
It's all about side-effects on the server side during reloading, remember?
<?
if ($fun == "add") {
$acc += $arg;
}
?> <html>
<head><title>Calculator</title></head>
<body bgcolor=white>
<form>
Your balance currently is: <?=$acc+0?> <p> Argument: <input type="text" name="arg"> <p> Function: <select name="fun">
<option value="non"> click me!
<option value="add"> deposit
<option value="sub"> withdraw
</select> <p> <input type="hidden" name="acc" value="<?=$acc+0?>">
When done push <input type="submit" value="Proceed"> </form>
</body>
</html>
Thu Jul 31
Wed Jul 30
Sat-Tue Jul 26-29
Fri Jul 25cp /l/www/classes/a348/spr2002/lectures/sc/item* .Here is the Fibonacci code, for your reference:
#!/usr/bin/perl
use CGI;
use DBI;
use MD5;
$DB = "DBI:mysql:a348";
$username = "a348";
$password = "a348AG";
$DB_TABLE = "dgerman_mar4";
$SECRET = "something secret";
$EXPIRE = 30 * 60 * 60 * 24; # one month
$MAX_TRIES = 10;
$ID_LENGTH = 8;
$q = new CGI;
$DBH = DBI->connect($DB, $username, $password, { PrintError => 0 })
|| die "Couldn't open database: ", $DBI::errstr;
my ($session_id) = &get_session_id();
print $q->header, $q->start_html;
my $state = &get_state($session_id);
if (! $state->{one}) { $state = &initialize($state); }
$state = &calculate($state);
&save_state($state, $session_id);
&status($state);
&show_form();
print $q->end_html;
$DBH->disconnect;
#--------------------------------(end of main program)------
sub show_form {
print $q->start_form(),
"When done please press ",
$q->submit(-value=>'Proceed'),
$q->end_form();
}
#--------------------------------(this was our basic form)---
sub get_session_id {
&expire_old_sessions();
my ($id) = $q->path_info =~ m:^/([a-h0-9]{$ID_LENGTH}):o;
return $id if $id and &check_id($id);
my $session_id = &generate_id;
die "Couldn't make a new session_id" unless $session_id;
print $q->redirect($q->script_name() . "/$session_id");
exit(0);
}
#--------------------------------(needed above)--------------
sub expire_old_sessions {
$DBH->do(<<END);
DELETE FROM $DB_TABLE
WHERE (unix_timestamp() - unix_timestamp(modified)) > $EXPIRE
END
}
#--------------------------------(also needed above)---------
sub generate_id {
my $tries = 0;
my $id = &hash($SECRET . rand());
while ($tries++ < $MAX_TRIES) {
last if
$DBH->do("INSERT INTO $DB_TABLE (session_id) VALUES ('$id')");
$id = &hash($SECRET . rand());
}
return undef if $tries >= $MAX_TRIES;
return $id;
}
sub hash {
my $value = shift;
return substr(MD5->hexhash($value), 0, $ID_LENGTH);
}
#--------------------------------(last one needed)-----------
sub check_id {
my $id = shift;
return $id
if $DBH->do("SELECT 1 FROM $DB_TABLE WHERE session_id = '$id'") > 0;
return $id
if $DBH->do("INSERT INTO $DB_TABLE (session_id) VALUES ('$id')");
return '';
}
#--------------------------------(retrieve acc)--------------
sub get_state {
my $id = shift;
my $query = "SELECT * FROM $DB_TABLE WHERE session_id = '$id'";
my $sth = $DBH->prepare($query) || die "Prepare: ", $DBH->errstr;
$sth->execute || die "Execute: ", $sth->errstr;
my $state = $sth->fetchrow_hashref;
$sth->finish;
return $state;
}
#--------------------------------(calculate new acc)---------
sub calculate {
my $state = shift;
$state->{one} = $state->{two};
$state->{two} = $state->{three};
$state->{three} = $state->{one} + $state->{two};
return $state;
}
#--------------------------------(store new acc)-------------
sub save_state {
my ($state, $id) = @_;
my $sth = $DBH->prepare(<<END) || die "Prepare: ", $DBH->errstr;
UPDATE $DB_TABLE
SET one = ?, two = ?, three = ?
WHERE session_id = '$id'
END
$sth->execute(@{$state}{qw(one two three)})
|| die "Execute: ", $DBH->errstr;
$sth->finish;
}
#--------------------------------(print current acc)---------
sub status {
my ($state) = @_;
print qq{
One: $state->{one} <p>
Two: $state->{two} <p>
Three: $state->{three} <p>
};
}
sub initialize {
my $state = shift;
$state = {} unless $state;
$state->{one} = 1;
$state->{two} = 1;
$state->{three} = 2;
return $state;
}
Thu Jul 24Use it in your shopping carts for the next lab.
<?
function get_book_cats($isbn) {
$conn = db_connect();
$query = "select dgerman_php_catboo.catid, catname
from dgerman_php_categories, dgerman_php_catboo
where '$isbn' = dgerman_php_catboo.isbn and
dgerman_php_categories.catid = dgerman_php_catboo.catid";
$result = @mysql_query($query);
if (! $result) return false;
$num_cats = @mysql_num_rows($result);
if ($num_cats == 0) return false;
$cat_array = array();
for (
$count = 0;
$row = @mysql_fetch_array($result);
$count++
)
$cat_array[$count] = $row;
if (! is_array($cat_array)) {
echo "No categories currently available. <br>";
}
foreach ($cat_array as $row) {
$url = "show_cat.php?catid=".($row["catid"]);
$title = $row["catname"];
do_html_url($url, $title);
}
}
?>
I will only show you a prototype in class, to see how it works. You need to obtain the same effect in your carts, and understand it.
Therefore the question is:
Wed Jul 23
$DB_TABLE = "dgerman_mar4";
$acc)
my $state = &get_state($session_id);
// ...
sub get_state {
my $id = shift;
my $query = "SELECT * FROM $DB_TABLE WHERE session_id = '$id'";
my $sth = $DBH->prepare($query) || die "Prepare: ", $DBH->errstr;
$sth->execute || die "Execute: ", $sth->errstr;
my $state = $sth->fetchrow_hashref;
$sth->finish;
return $state;
}
if (! $state->{one}) { $state = &initialize($state); }
$state = &calculate($state);
// ...
sub calculate {
my $state = shift;
$state->{one} = $state->{two};
$state->{two} = $state->{three};
$state->{three} = $state->{one} + $state->{two};
return $state;
}
&save_state($state, $session_id);
// ...
sub save_state {
my ($state, $id) = @_;
my $sth = $DBH->prepare(<<END) || die "Prepare: ", $DBH->errstr;
UPDATE $DB_TABLE
SET one = ?, two = ?, three = ?
WHERE session_id = '$id'
END
$sth->execute(@{$state}{qw(one two three)})
|| die "Execute: ", $DBH->errstr;
$sth->finish;
}
sub status {
my ($state) = @_;
print qq{
One: $state->{one} <p> Two: $state->{two} <p> Three: $state->{three} <p> };
}
save_state again:
sub save_state {
my ($state, $id) = @_;
my $sth = $DBH->prepare(<<END) || die "Prepare: ", $DBH->errstr;
UPDATE $DB_TABLE
SET one = ?, two = ?, three = ?
WHERE session_id = '$id'
END
$sth->execute(@{$state}{qw(one two three)})
|| die "Execute: ", $DBH->errstr;
$sth->finish;
}
generate_id:
sub generate_id {
my $tries = 0;
my $id = &hash($SECRET . rand());
while ($tries++ < $MAX_TRIES) {
last if
$DBH->do("INSERT INTO $DB_TABLE (session_id) VALUES ('$id')");
$id = &hash($SECRET . rand());
}
return undef if $tries >= $MAX_TRIES;
return $id;
}
Compared to Lab Six the $acc is not there.
initialize:
sub initialize {
my $state = shift;
$state = {} unless $state;
$state->{one} = 1;
$state->{two} = 1;
$state->{three} = 2;
return $state;
}
There was no need to initialize in Lab Six.
Tue Jul 22
Mon Jul 21
frilled.cs.indiana.edu%ls -ld *
-rw------- 1 dgerman faculty 828 Jul 22 11:21 BankAccount.pm
-rwx------ 1 dgerman faculty 340 Jul 22 11:26 something
frilled.cs.indiana.edu%cat Bank*.pm
package BankAccount;
use strict;
use warnings;
sub nuovo { // if you speak Italian...
my $class = shift;
my $balance = shift;
my $account = { # my instance variable (a hashtable of one)
balance => $balance
};
bless $account, $class; # let the hashtable become an object of this class
return $account; # we never do this in Java
}# this is the constructor...
sub getBalance {
my $this = shift;
return $this->{balance};
}
sub deposit {
my $this = shift;
my $amount = shift;
$this->{balance} += $amount;
}
sub withdraw {
my $this = shift;
my $amount = shift;
$this->{balance} -= $amount;
}
return 1; # needed for modules imported with use
# such modules are imported during the compilation phase
# it indicates that the module has been successfully imported
frilled.cs.indiana.edu%cat some*
#!/usr/bin/perl
use BankAccount;
$adrian = nuovo BankAccount(30); // italiano vero...
print "account created, current balance is: ", $adrian->getBalance, "\n";
$adrian->deposit(20);
print "deposit 20, current balance now: ", $adrian->getBalance, "\n";
$adrian->withdraw(10);
print "withdraw 10, balance becomes: ", $adrian->getBalance, "\n";
frilled.cs.indiana.edu%./something
account created, current balance is: 30
deposit 20, current balance now: 50
withdraw 10, balance becomes: 40
frilled.cs.indiana.edu%
Sun Jul 20
Sat Jul 19Don't try to make any appointment just yet, I need to reset it first.
Fri Jul 18
I will be posting them soon.
Thu Jul 17There is no Lab Seven and nothing but the lab for today is due on Monday.
If you finish your lab today (or, if you have done it already just show it to us today) then you're done.
Here's a bit of help in case you're still working on it.
My script has been enhaced a bit.
Here's the written
part of the midterm exam administered in class today.
Appointments for the practical part of the exam
If you call it with no arguments it retrieves and displays data.
If you give it arguments like this
http://burrowww.cs.indiana.edu:11400/cgi-bin/july17
it should do what you ask of it.
Here's my source code as of right now:
http://burrowww.cs.indiana.edu:11400/cgi-bin/july17?what=insert&number=100&category=English+Literature
Advice: instead of determining what needs to be done and choosing
between insert or update one can simply delete (if anything) and then
insert. If delete fails nothing unusual happens. So maybe this simplifies
things. You can also work out some HTML form interface if you want. #!/usr/bin/perl
use DBI;
use CGI;
$q = new CGI;
print "Content-type: text/html\n\n";
$DB = "DBI:mysql:a348"; # data source name (database)
$username = "a348"; # username
$password = "a348AG"; # password
$dbh = DBI->connect($DB, $username, $password, {PrintError => 0})
|| die "Couldn't open database: ", $DBI::errstr;
if ($q->param('what') =~ /^insert$/i) {
$catNo = $q->param('number');
$catTitle = $q->param('category');
$query = "insert into dgerman_php_categories values (" .
$catNo . ", " . $catTitle .")";
print $query, $q->end_html; exit;
} else {
}
$sth = $dbh->prepare('SELECT * FROM dgerman_php_categories')
|| die $dbh->errstr;
$sth->execute() || die $sth->errstr;
print "<table border cellpadding=2>",
"<tr><th> Category No. <th> Category Title";
while (my $row = $sth->fetch) {
my($catNo, $catTitle) = @$row;
print "<tr><td align=center>$catNo <td align=center>$catTitle";
}
print "</table>";
$sth->finish;
Wed Jul 16
Tue Jul 15#!/usr/bin/perl
use CGI;
$request = new CGI;
print $request->header;
print $request->start_html;
$uname = $request->param('username');
if ($uname) {
open (AB, "/u/dgerman/apache/apache_1.3.26/htdocs/july15/.htaccess");
@lines = <AB>;
close(AB);
# alternative way of reading the file
# while ($line = <AB>) {
# print $line;
# }
print "I will add this user: ", $uname;
$file = join('', @lines);
$file =~ s/<\/Limit>/ require user $uname\n<\/Limit>/;
open (AB, ">/u/dgerman/apache/apache_1.3.26/htdocs/july15/.htaccess");
print AB $file;
close(AB);
} else {
print "Nothing to do...";
}
print $request->end_html;
Note there are two new links under MIDTERM and CATCHUP. Please
explore them. A note regarding details on the installation of PHP from last semester:
Date: Fri, 28 Feb 2003 17:04:17 -0500
From: Rob Henderson <robh>
To: dgerman@cs.indiana.edu
Subject: burrowww /tmp usage
There are quite a number of users in the burrow that appear to
be building php and/or apache in /tmp on burrowww. On all the
department Suns, /tmp is a memory filesystem so this is chewing
up a lot of virtual memory on the system. Whenever a user needs
a large temporary space, they should use /scratch or /nobackup and
they can see:
http://www.cs.indiana.edu/Facilities/FAQ/General/storage.html
for information about how to use these.
I'm not sure if these students are in your class or not, but
perhaps you could spread the word that /tmp is not a place
to be putting lots of files?
Thanks a bunch!!
--Rob
Here's
the code for this script:
#!/usr/bin/perl
use DBI;
print "Content-type: text/html\n\n";
$DB = "DBI:mysql:a348"; # data source name (database)
$username = "a348"; # username
$password = "a348AG"; # password
$dbh = DBI->connect($DB, $username, $password, {PrintError => 0})
|| die "Couldn't open database: ", $DBI::errstr;
$sth = $dbh->prepare('SELECT * FROM dgerman_php_categories')
|| die $dbh->errstr;
$sth->execute() || die $sth->errstr;
print "<table border cellpadding=2>",
"<tr><th> Category No. <th> Category Title";
while (my $row = $sth->fetch) {
my($catNo, $catTitle) = @$row;
print "<tr><td align=center>$catNo <td align=center>$catTitle";
}
print "</table>";
$sth->finish;
Your lab assignment is to enhance the functionality of this script
in a meaningful way. That means you should make provisions for all three operations:
Please read the notes from July 9.
Nothing can be done without them!
Mon Jul 14Here's where you can get PHP to install it:
frilled.cs.indiana.edu%ls -ld /l/www/classes/a348/software/php* -rw-r--r-- 1 dgerman faculty 3371385 Feb 18 12:21 /l/www/classes/a348/software/php-4.1.0.tar.gz -rw-r--r-- 1 dgerman faculty 26660 Mar 6 19:03 /l/www/classes/a348/software/php.ini frilled.cs.indiana.edu%Please note that there is a catch-up lab this week on Thu.
More details will be given in class and summarized here later today.
Sun Jul 13A348-4294).
Sat Jul 12class BasicCalculator {
int add(int n, int m) {
if (m == 0) return n;
else return add(n+1, m-1);
}
}
class BetterCalculator extends BasicCalculator {
int add(int n, int m) {
if (m < 0) return -super.add(-n, -m);
else return super.add(n, m);
}
}
class Experiment {
public static void main(String[] args) {
BetterCalculator a = new BetterCalculator();
System.out.println(a.add( 2, 3));
System.out.println(a.add(-2, 3));
System.out.println(a.add( 2, -3));
System.out.println(a.add(-2, -3));
BasicCalculator b = new BasicCalculator();
System.out.println(b.add( 2, 3));
System.out.println(b.add(-2, 3));
// System.out.println(b.add( 2, -3)); // won't work (don't even try)
// System.out.println(b.add(-2, -3)); // won't work (don't even try))
}
}
/*********************************(sample run)*******
frilled.cs.indiana.edu%javac Experiment.java
frilled.cs.indiana.edu%java Experiment
5
1
-1
-5
5
1
frilled.cs.indiana.edu%
*****************************************************/
Improvement assumes you can't or don't want to touch the code you already have.
(That is the add in the class BasicCalculator).
Fri Jul 11I will in fact develop it in class on Monday.
Thu Jul 10Basically:
The only tricky thing is the composite primary key of catboo.
Wed Jul 9
class Calculator {
int add(int n, int m) {
if (m < 0) return -add(-n,-m);
else if (m == 0) return n;
else return add(n+1, m-1);
}
public static void main(String[] args) {
Calculator a = new Calculator();
System.out.println(" 1 + 2 = " + a.add( 1, 2));
System.out.println(" 4 + 1 = " + a.add( 4, 1));
System.out.println("-1 + 2 = " + a.add(-1, 2));
System.out.println("-1 + -2 = " + a.add(-1, -2));
}
}
/*****************************(sample use)****
frilled.cs.indiana.edu%javac Calculator.java
frilled.cs.indiana.edu%java Calculator
1 + 2 = 3
4 + 1 = 5
-1 + 2 = 1
-1 + -2 = -3
frilled.cs.indiana.edu%
**********************************************/
Tue Jul 8The PDF is indexed under What's New for June 9.
The HTML version of the ClassPak from Spring is indexed under Class Notes at the top.
Mon Jul 7
Design and describe an experiment that makes use of no browser and uses the simplest possible CGI script (written in Perl) that clearly states the difference between the request methods GET and POST. Turn in a statement of this difference and a written description of your experiment's steps (and the code).Lab Assignments are due at the end of the lab.
Also, make sure you're done with Lab Notes Four by the end of the day.
Fri-Sun Jul 4-6They need to be updated a little, but they're accurate already.
Thu Jul 3Lab assignment today: disable dgerman/kling0n access to your protected.
Add the following to your passwd file: dgerman:e5WZe30aYm0Z.
See you in class.
Wed Jul 2I have to post a few other links.
Please also note my office hours are now only in LH201D (my office).
Tue Jul 1We'll post more information on these soon.
Mon Jun 30
drwxr-xr-x 2 dgerman faculty 512 Jan 30 2002 tutorial
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/jun30
burrowww.cs.indiana.edu% ls -l
total 2
-rwx------ 1 dgerman faculty 303 Jun 30 10:33 calc
-rwx------ 1 dgerman faculty 58 Jun 30 11:17 clock
burrowww.cs.indiana.edu% cat clock
#!/usr/bin/perl
$time = localtime;
print $time, "\n";
burrowww.cs.indiana.edu% ./clock
Mon Jun 30 11:17:54 2003
burrowww.cs.indiana.edu% ./clock
Mon Jun 30 11:17:58 2003
burrowww.cs.indiana.edu% date
Mon Jun 30 11:18:00 EST 2003
burrowww.cs.indiana.edu% cat calc
#!/usr/bin/perl
$acc = 0;
print "enter> ";
while ($line = <STDIN>) {
($fun, $arg) = split(/ /, $line);
if ($fun =~ /add/) {
$acc += $arg;
} elsif ($fun =~ /sub/) {
$acc -= $arg;
} else {
print "What's ", $fun, "?\n";
}
print "accumulator now: ", $acc, "\nenter> ";
}
burrowww.cs.indiana.edu% ./calc
enter> add 1
accumulator now: 1
enter> sub 3
accumulator now: -2
enter> add 6
accumulator now: 4
enter> sub 24a
accumulator now: -20
enter> bye
What's bye
?
accumulator now: -20
enter> burrowww.cs.indiana.edu%
Note that you need to use the clock program for your
lab assignment today which will be: write a script that prints the
time on the server (in the browser). Like this.
Of these 161 questions please extract at least 10 (ten) that refer to this past first week of classes.
Fri-Sun Jun 27-29I will come to lab on Monday. I will write some more on Sunday when I return.
Date: Fri, 27 Jun 2003 14:42:55 -0500 (EST) From: Adrian German <dgerman@cs.indiana.edu> To: A348 Summer 2003 Distribution List <dgerman@indiana.edu> Subject: A348/A548 update. Dear A348/A548 Friends, Allow me to thank Barry (Yinggang) Li for his gracious help with the lecture on Thursday. Monday I will come to your lab and we'll be able to touch base with each one of you. Also, after Monday when I want to come to both A201 and A348 labs which will take the entire day if we include the lectures too, my office hours will be 3-4pm (LH201D) and 5-6pm (LH016) daily. Now I am off to Columbus, Ahia, for the weekend. See you when I return. I will be grading both Lab One and Lab Two as well as Homework One (which has been extended one day) next week, with Barry. I hope you have a great weekend and my very best to all of you. You are simply the best. ... Adrian
Thu Jun 26dgerman@indiana.edu) and
I will get to your messages in the evening, when I return.
Wed Jun 25
Don't forget to chmod 711 ~ and chmod 755 ~/public to
allow access to the archive.
You also need to be able to make the archive readable as well.
Tue Jun 24The list is also available from the Class Notes section of the course web page.
Mon Jun 23