533 First Day Exercise
One
- logon to a unix computer and
go to the shell
dante28%
- call the pico editor
dante28% pico
- type in the following two
lines:
#! /usr/local/bin/perl5
print ("Hi Terry\n");
- save your work under the file
name "one"
- at the prompt, call your file
with the perl compiler:
perl one
Does your perl program run?
Two
- call the file "one"
with the pico editor
- change it to read:
#! /usr/local/bin/perl5
use CGI qw(:standard);
print header, start_html;
for ($i = 1; $i <= 3; $i++) {
print ("Hi Terry\n");
}
print end_html;
- when you exit pico, save this
file to "one.cgi"
- test your file by issuing the
command:
dante%28perl one.cgi ""
is the response formatted like html?
- change the file permissions
with the unix chmod command:
dante%28 chmod 755 one.cgi
- find out where one.cgi is
located by using the unix command pwd:
dante%28 pwd
- point your favorite browser
at the url
Did your file come up in the browser?
Extra points bonus question: How
would you format the output with "<br>"?
Three
- open Wordpad
- type in the following lines:
<html>
<body>
Here is the date:<br>
<script language = "javascript">
today = new Date();
document.write(today.toLocaleString());
</script>
</body>
</html>
- save the file as
"java.htm" with the "text" type in a special
subdirectory
- point your browser at
java.htm
did you
see a date?
Four
- open the DOS prompt and find
your way to the special subdirectory where java.htm is located
- use "edit" and type
in the following file:
import java.awt.*;
import java.applet.*;
public class hello extends Applet {
public void init() {}
public void paint (Graphics g) {
g.drawString("Bingo Bobbins", 20, 20);
}
}
- save the file as
"hello.java"
- call the java compiler
"javac" with the command:
javac hello.java
- display your directory to see
if you have a file called "hello.class"
- use "edit" again to
modify the file "java.htm" to look like:
<html>
<head>
<body>
Here is the date:<br>
<script language = "javascript">
today = new Date();
document.write(today.toLocaleString());
</script>
<br>
<applet code="hello.class"
height = 150
width = 150>
</applet>
</body>
</html>
- at the DOS prompt, check the
applet by using "appletviewer":
c:\mysubdirectory\ appletviewer java.htm
Did you see your applet?
- finally, point your browser
at java.htm