Mode Tutorial

Topics: Telnet, Unix, Programming, Web Pages, Email,
Unix Commands: cat, CC, cd, .forward, java, javac, logout, ls, passwd, pico, pine

Telnet

As long as you have an active internet connection, you may connect to the Mode machine via the telnet application on your computer. You will be prompted for your AiS Challenge username and password.

Mode is the high-performance computer available for AiS Challenge participants.

Connect to Mode using the telnet application on your PC. From the "start" menu in the lower left-hand corner of the screen, select run. Type in "telnet mode.lanl.k12.nm.us" (without the quotes) and click on OK.

You will then be prompted for your username and password. Be aware that your password will not display to the screen as you are typing it in!


Unix

Unlike a PC or Mac, Mode does not run a Graphical User Interface (GUI). Mode runs Unix - an operating system which is typically text-based. In order to develop programs, create web pages, and access email, you will need to learn a host of text-based Unix commands and utilities.

Upon connecting to Mode, you are positioned within your home directory (folder). Type the "ls" command at the prompt to see what files and directories you have.

ls
The ls command will list the contents of the current directory. You will see the names of files and directories (folders) displayed to the screen.
Example: ls

Keep in mind that Unix is a text-based operating system. You will not see pictures of files and folders representing these items — only their names!

Notice that you have (at least) the following items:

  • A Java program named "Add.java"
  • A directory (folder) named "public_html"
For easy identification, directories (folders) will have a forward slash appended to the end of their names.

To quickly view the contents of files, you may use the "cat" command.

cat
The cat command will display the contents of a file to the screen.
Example: cat Add.java

View the contents of Add.java using the "cat" command. Keep in mind that Unix is case-sensitive!

At this time, you may now change the cryptic password you were supplied with at registration. The "passwd" command will allow you to do this. Be aware that your old/new passwords will not display to the screen as you are typing them in!

passwd
The passwd command will change your mode password. The user is first prompted for their old password. Then, the user is prompted for a replacement password. This password is tested for complexity. If the password is accepted, passwd will prompt again and compare the second entry against the previous one. Both entries are required to match in order for the password to be changed.

If you use the passwd utility, make sure you remember your new password!


Programming

Programming utilities are available for the Java, C, C++, and Fortran languages. Others, such as Perl and Python, are also available.

You will not learn how to write a computer program from this tutorial — you must learn that on your own. You will, however, learn about the process of editing, compiling, and executing (running) computer programs on the Mode machine.

To create a new file, or to edit an existing file (e.g. files which contain Java or C++ programs), you may use the "pico" utility.

pico
pico is a very simple text editor. It is always in "insert mode" and shows the possible control commands on the bottom of the screen. The arrow keys can be used to position the cursor and characters can be deleted with either the delete key or the backspace key.
Example: pico Add.java

Java

The Java program, Add.java, adds two numbers and displays the results. This program, however, is incomplete — you will add in the missing code to make it work!

Use pico to edit the Java program named "Add.java". Compare the file that you have to the complete program shown below. Make whatever changes are necessary so that they look exactly the same — keep in mind that Java is a case-sensitive language!

 public class Add {
  
   public static void main(String args[]) {
  
     double sum;
  
     sum = Double.parseDouble(args[0]) + Double.parseDouble(args[1]);
     System.out.println(sum);
  
   }
 }

When you are finished, compile the file (i.e. turn the source code into an executable program which can be used) by using the "javac" command:

javac
Use the javac command to invoke the Java compiler. It will translate files of java source code (i.e. ending with ".java") and produce new files of java byte code. These new files will have a ".class" extension.
Example: javac Add.java

If you made all of the correct edits, the above command (javac Add.java) will have created a new file named "Add.class". This is the program we can actually execute (run). If you get error messages, it will not create this executable file — you must then re-edit the file and try to compile it again.
Use the "ls" command to see that it did (or did not) create an executable file named "Add.class".

You now can execute the program by using the "java" command.

java
The Java interpreter, sometimes reffered to as the Java Virtual Machine (JVM). Used to execute java programs (files that end with ".class").

Execute the program by issuing the command "java Add NUM1 NUM2" where NUM1 and NUM2 are the actual numbers to be summed up.
Example: java Add 8.4 19.6

C++

Create a C++ Program from scratch! Issue the command "pico add.c" to create the source file for a program named add.c. This program will also add two numbers and display the results to the screen. The code you should enter into the file is shown below:

 #include <iostream>
 
 using namespace std;
 
 int main (int argc, char **argv) {
 
   double sum;
 
   sum = atof(argv[1]) + atof(argv[2]); 
   cout << sum << endl;
 
 }

When you are finished, compile the file (i.e. turn the source code into an executable program which can be used) by using the "CC" command:

CC
The CC command will invoke the C++ compiler to compile a C++ program. The -o option will name the output file differently from the default name of a.out.
Example: CC -o add add.c

If you typed in the program correctly, the above command (CC -o add add.c) will have created a new file named "add". This is the program we can actually execute (run). If you get error messages, it will not create this executable file — you must then re-edit the file and try to compile it again.
Use the "ls" command to see that it did (or did not) create an executable file named "add".

You now can execute the program by issuing the command "add NUM1 NUM2" where NUM1 and NUM2 are the actual numbers to be summed up.
Example: add 8.4 19.6


Web Pages

Mode is also a web server. You may make AiS Challenge related web pages available to the public by placing them in your 'public_html' directory (folder). Use the "ls" command to see that you do indeed have this item.

To move into your public_html directory, use the "cd" command.

cd
The cd command will move you into another directory. If no directory is specified, cd will return you to your home directory.
Example: cd public_html

Move into your public_html directory, and issue an "ls" command to view the contents. Items in this directory can be viewed over the web with a browser!

View the contents of the file named "index.html" with the cat command. This file is a web page written in HTML. Now, view it over the web by pointing your web browser to:

http://mode.lanl.k12.nm.us/~ch099abc/
where ch099abc is replaced with your login name.

Feel free to edit this file using pico. When you save changes to this file (or any web page), you may not see the changes take place immediately on the web until you press the "reload" or "refresh" button on your web browser.

NOTE: "index.html" is a very unique file. To view ANY other web page which resides in this folder, you must point your web browser to:

http://mode.lanl.k12.nm.us/~ch099abc/NAME_OF_FILE.html
where NAME_OF_FILE.html is replaced with the actual file name.

You may test this out by looking at the other file you have in your public_html directory! Point your web browser to:

http://mode.lanl.k12.nm.us/~ch099abc/abstract.html
where ch099abc is replaced with your login name. Note that this "abstract" file is just there for you to practice with. It is not a file that you have to edit and submit to us.

Finally, go back to your home directory by issuing a "cd" command. Simply type cd at the prompt and hit enter.


Email

Every AiS Challenge participant receives an email account for the year. You may access this account via a text-based tool, or by a graphical web-based tool.

NOTE: AiS Challenge email addresses are in the form of "ch099abc@mode.lanl.k12.nm.us", where ch099abc is replaced with your login name.

From the telnet interface, you may read and compose messages by using the "pine" email utility.

pine
pine is an electronic mail program that is very friendly and easy to use. It uses pico to create new messages. There is help on each screen of pine, where possible commands are listed on a menu or across the bottom of the screen.

Using pine, send mail to your team members to establish a time this week to discuss what you hope to learn at Glorieta. Simply type pine and press enter to begin.

NOTE: If you provided an email address when you registered, we have (or will in the future) put the address into a file in your home directory named .forward

.forward
If you already have a primary email account, you may have email that is sent to your AiS Challenge account redirected to your primary account. A file named ".forward" contains information on how to perform this redirection.

To create/edit this file on your own, enter "pico .forward". Type in your primary email address, like Joe-student@aol.com, and save the file (^O ^X). Test it by sending mail to your mode account (i.e. ch099abc@mode.lanl.k12.nm.us) and see if that mail shows up at your other account. If not, re-edit your .forward file and try again.

NOTE: Files that begin with a period (like .forward) will not appear when you issue an ordinary "ls" command! They are hidden files ...

A web-based mail utility is also available for you to use. Simply point a web browser to:

http://www.challenge.nm.org/mail
Login, as you do to mode, and check your email.


Final Step!

Congratulations! You have finished this tutorial. You may now leave the Mode machine by using the "logout" command.

logout
Don't forget to logout when you are finished using mode.lanl.k12.nm.us so that others will not bother your files and you will not use any system resources.
Example: logout

October 2003
Document URL--http://www.challenge.nm.org/archive/03-04/glorieta/curriculum/mode_tutorial.shtml