Welcome to "Stats"
The Academic Computer Server
at the
College of William and Mary

(A Users Guide by Bob Dawson, Academic User Support)


"Stats" was formally known as "Aardvark", an isolated UNIX server. "Stats"is more complex in that it shares its files with Netstore "H"drive disk storage

Note: unless indicated otherwise any links to supporting documents (e.g., Netstore above) are those located at "http://jrdaws.people.wm.edu" (alias "bobsweb.org"), the same web site as this document.

Table of Contents
I. Introduction
II. Getting Started with Two Examples

A. The Fortran Example
B. The X-Windows Stata (Xstata) Example

III. How to Access Stats/Create Files on Stats
A. Overview
B. Accessing Stats
C. Methods for Creating Files on Stats: Details
(1) By Creating Files onto "H:" (Shares Files with Stats)
(2) By SFTPing Files on Your PC to Stats
(3) By Executing Stats Software and File Commands
(4) By Using One of Stats's Text Editors
IV. How to Print Stats Output
V. How to Compile/Run Programs in Fortran, C,  Perl, or Java
A. How to Compile/Run Fortran Programs
B. How to Compile/Run C Programs
C. How to Compile/Run  Perl Programs
D. How to Compile/Run  Java  Programs
E. How to Continue Running a Program after Exiting Stats
VI. How to Run Statistical/Math Software and the Mailer "Pine"

A. How to Run Stata
B. How to Run SAS
C. How to Run Matlab
D. How to Run Maple
E. How to Run/Use the Mailer "Pine"

VII.  An Introduction to Stats UNIX Commands
VIII.How to Manage Your Files on Stats

A File Managing via Windows Explorer when "H:" Accessible
B. File Managing via Stats Commands.
IX A Stats UNIX Selected Command Summary

Appendix A: The Fortran Example Program

I. Introduction (GoBack)

Got a huge data set at William and Mary that you want to statistically analyze but it won't fit on your PC? Or if it  did, you want others at W & M possibly  in other disciplines to access the same data and share in the analysis using the same software? Or you just don't have the necessary software to do the analysis on your own personal computer? Or you are a UNIX user in search of a UNIX computer to do your academic work?

Well welcome to "Stats", remote server for academic computing at William and Mary. With Stats, a SUN computer controlled by a Solaris 9 UNIX system, you can run statistical and math software or compile/run programs written in a variety of languages. On Stats you do all of this remotely using remotely stored data that in most cases is accessible on your own PC, while the software and the data itself doesn't have to be on your PC; once more others at William  and Mary can access/use the same data by copying it via the WEB to their remote Netstore"H:" drive storage, accessible via "Stats" because it shares files with "H" storage. And finally everyone at W & M has access to Stats (i.e., all can log into Stats), which means that everyone can now access their "H" drive storage via Stats (which again shares storage with "H"). For more about the Solaris 9 UNIX system beyond this document go to "docs.sun.com".

Stats has four processors, each able to run at the speed of 750 MHz (faster than most lab computers and definitely a step up for those who use the  UNIX system on a PC insufficient to support the PC Windows system); 6 more SUN  processors  can be added. For random storage  Stats has  12 GB of RAM; for local disk storage,  six 34 GB hard drives, three for the UNIX system and software that it supports, three for scratch storage. Again user disk storage is common with that on the "H:" drive  (officially referred to as "Netstore"); this means that user disk files on Stats can be readily accessed from  PC's that map to "H" storage;  (this includes PCs in the  labs, many desktops  in  W & M offices, and many other W & M  personal computers in the residence halls). Large data sets such as the US Census Data reside on  Stats and are stored on the  3 TB W & M remote disk storage NAS (Network Access Storage) which satisfies other disk storage requirements at W & M such as that of the "H:" drive; these data sets can be accessed via Stats or directly by mapping a PC to NAS. Stats  users can request software and/or data set additions to Stats  by E-Mailing  IT Unix Liaison James Strawn (E-mail: jestra@wm.edu ), Ex 1-1934. What data additions are currently available can be found by executing the UNIX command "mount"; the user still requires getting permissions to access this data.

Stats's has the following core software listed by category:

(1) Compilers/Programming Languages:  Fortran, C,  Perl,  Java, Python, and GCC.
(2) Math Software: Maple and Matlab
(3) Statistical Software: Stata, SAS, and again Matlab

II. Getting Started with Two Examples(GoBack)
 
  A. The Fortran Example (GoBack)

Assume you have a Fortran program to display the simple means of each variable in the following data:

Age  Income  Education25   40      4
27   45      5
31   42      4
33   47      6
40   53      7
where simple means =  sum divided by N (# of cases -- lines).

Also assume that you will enter the data interactively at Stats's command line and the same time your Fortran program will store a copy of the entered data in file "fort.5".  Typically of course the data would be much larger, read from a file, and the output considerably more extensive; the simplicity of the example, however, readily illustrates how to access Stats, compile/run a Fortran program, display  the results, print it, and later direct to a file and print it from there too (see Appendix A to see the  Fortran program).

Lastly  assume that you will be accessing Stats from a W & M lab PC; that the Fortran program was created in the lab with a "txt" editor (e.g., Word Pad or NotePad -- Microsoft Word not recommend because of special character problems); that it resides in a "txt" file named "myprog.f" (after saving it in "myprog.txt" and renaming it to "myprog.f" -- see Appendix A II for more about creating/saving/renaming in the Labs); and that it is located on your "H:" drive (the remote disk space  at W & M, where each user accesses private disk space).

To run "myprog.f" on Stats you obviously need to access it from Stats; this is easily done in the W & M labs because the "H:" drive on which "myprog.f" exists shares your Stats account disk space (your Stats home space); thus when you log into Stats as discussed below, you have automatic access to this same file. However, because text PC files have "Carriage Return (CR)" characters that end each line, it may be necessary to remove the CRs before using the files;  you can do this via the Stats utility "dos2unix". In the case of "myprog.f" this is not necessary since Fortran on Stats ignores the CRs (were it necessary we illustrate how to use "dos3unix below to remove the CRs from "myprog.f"). If you are on a PC other than in the labs you may not be able to access the "H:" drive. Then it will be necessary to  file transfer "myprog.f"  to Stats using SFTP to do it in a safe, secure manner; to learn how to do this in the labs go to PACLab Tips, Appendix D. If you do not have SFTP installed on your computer, you can download it from the IT Software Repository site at software.wm.edu (at this site click Internet Browser and Network Tools under Windows software and then click SSH Secure Shell Client to download SFTP; it will appear as SSH Secure File Transfer Client after downloading -- see Appendix A II 2nd paragraph for more; you will also have available on your own PC "F-Secure SSH Client" for logging into Stats discussed next using the lab version).

Now you need to access Stats itself so that you can compile and run your Fortran program; you do this by SSHing to Stats and logging into the remote computer.  In the lab you do this  via "F-Secure SSH Client" which will access "Stats" in the safe, secure mode (but not necessarily in the X-Windows mode required by X-Windows programs like Xstata -- see II.B. below for an Xstata example); you start by clicking F-Secure SSH Client (reached via Programs, Internet and Commutations, then F-Secure SSH Client again) and follow Steps 2 thru 5 of the instructions in PACLab Tips, Section II. 8. (b) . You should now be SSHed to Stats and  logged into the remote UNIX computer.

Once you have SSHed and logged into Stats, you should be in a"F-Secure SHH Client" window showing Stats in the command line mode (the "F-Secure SSH" indicates that you are in the safe, secure mode); here you are prompted with a "$" to enter a Stats command.  As mentioned above, because Stats shares the "H:" drive disk space, your Fortran program in file "myprog.f" should simultaneously reside in your personal disk space on Stats; it should, therefore, be accessible as soon as you log into Stats.

Let us assume that before you can compile your Fortran program in "myprog.f", you need to first remove the "Carriage Return (CR)" characters that your PC ends each line of a "txt" file but which Stats doesn't recognize;  as mentioned above Stats Fortran actually ignores the CRs, but we illustrate removing the CRs in case you need to do it with another applications. To remove the CRs  you enter the following at the Stats command line:

dos2unix myprog.f  > temp
cp temp myprog.f
To compile your program,  all you have to do is type this command:
f77 -o myprog.out myprog.f
where "-o myprog.out" specifies that the compiled results should go into file "myprog.out".

Assuming  no compiler errors occur, you compiled program should be in  file myprog.out and  all you do to run it is type:

./myprog.out
at the Stats command line; "myprog.out" now  prompts you enter your data with this display:
Enter one case for age, income, and education (all 0's quits)
After you type the above data, one line at a time, you terminate the entry by keying "0 0 0" to signal the end of the data input. Your Fortran program now shows the simple mean (average) of each variable in this manner on your lab PC monitor:
Variable       age   income  education
mean         31.20    45.40       5.20
To print the displayed output, just select it (i.e., highlight it by dragging the mouse across), then click File (main menu of the "F-Secure SSH Client" window), then Print, and then OK.

Alternately to put the same output in a file, you type this modification of the above "myprog.out"  command:

 ./myprog.out  < myprog.dat  >  myprog.lst
where "myprog.dat" contains a copy of "fort.1" which has the  data you interactively entered above  ( the copy acquired by executing  the Stats command: "cp fort.1 myprog.dat")  and where " > myprog.lst" tells Stats to put all displayed output (including the prompting text) into file "myprog.lst". Your averages should now be in file "myprog.list".

To print the output in file "myprog.lst" on a lab printer, you first display its contents by typing this Stats  command

cat myprog.lst
From here on its the same as printing the Averages  when displayed directly from the program (see above): you select the text to print, click File, Print, and then OK.

Of course you might want to modify "myprog.f" and run it again, possibly to make it output the unbiased mean of each variable  instead of the simple mean (the summation of cases divided by n); this simply requires dividing each variable's summation by (n-1) instead of n. You can readily change it on your lab PC (again, for example, Word Pad, NotePad). If you had to SFTP ".myprog.f" to access it from Stats, you might prefer using a Stats editor such as Edit,  VI,  Xemacs, or Pico to make the changes to "myprog.f".  In fact you might prefer creating the Fortran program from scratch using one of these editors on Stats and continue to use it to make changes. See III.C(4) below for more about Edit, VI,  Xemacs, and Pico.

B. The X-Windows Stata (Xstata) Example (GoBack)

Assume you want to use UNIX X-Windows Stata (Xstata) on Stats to plot the age of trees randomly chosen versus their aging condition (the proportion of dead cells to living cells); further assume that the following data represents the random trees:

tree_age     percent_live
55            95.2
40            96.7
35            97.9
23            98.3
11            99.5
 2           100.0
where you will enter the data into Xstata's Editor (spreadsheet) Window and at Xstata's command line, create the aging variable and plot tree age against aging.

Typically, the data would be much larger, read from a file, and the output more extensive; but as with the Fortran example above, the simplicity of the example here readily illustrates how to access Stats in X-Windows mode and do the following:

Start Xstata.
Enter/define data.
Generate variables.
Plot two variables.
View and print the results.
Save the data for later use.

As with the  Fortran example assume that you access Stats from a W & M lab PC. Again  to run Xstata on Stats you must access Stats in X-Windows mode; you start by clicking F-Secure SSH Client (reached via Programs, Internet and Commutations, then F-Secure SSH Client again) and follow Steps 1 thru 6 of the instructions in PACLab Tips, Section II. 8. (b). You should now have SSHed to the Stats computer and be logged in X-Windows mode; then just as Step 6 says you type "xstata" and bring up Stata/X-Windows (an environment very much like PC Stata/Windows in PACLab).

X-Windows Stata for Unix starts with opening its main window (labeled  "Stata/SE 8.2" -- you may have to click its icon on the Task Bar to actually open the window); it is composed of sub windows as follows:

The "Results" window for displaying the output (upper right)
The  "Command Line"  window (unlabelled, bottom right -- starts with vertical cursor in upper left of the  sub window)
The "Review" window for recording what you type in the "Command Line" window
The "Variables" window for listing current variables -- those accessible after reading/entering data

The stuff in "Review" and "Variables" can be placed in the "Command Line" window for editing/executing by simply clicking on it.

You now open Xstata's Data Editor Window (typical spreadsheet environment) by clicking  the spreadsheet icon on the toolbar (labeled "Data Editor" when mouse pointer passed across it); here you enter and define your example tree data above. You start by entering the "tree_age" values in column 1 of the Editor, and then the "Percent_live" values in column 2. Specifically,  you enter 55 (which appears in the "var1(1)=" text box) for cell 1, column 1 as the 1st value of tree_age and press the Enter key; this registers 55 (make it appear in cell 1, column 1) and moves you down to cell 2 in column 1. You now enter 40 for the 2nd value, press Enter and continue likewise-- then on to column 2 to enter "percent_live", etc.

 Now you define the variable names;  by default column 1 is named "var1", column 2, "var2". You double click the "var1" label, open a dialogue box where you rename "var1" to tree_age"; you click OK and "var1" becomes "tree_age" in column 1. Similarly you  change "var2" to "percent_live".

Close the Editor (close, not minimize -- the data will stay); you now generate the variables "percent_dead" and "aging" by entering/executing the following Xstata commands in the "Command Line" window (bottom right sub window):

Generate  percent_dead = 100-percent_live
Generate aging = percent_dead/percent_live
Finally you enter/execute this plot command to plot "tree_age" against "aging" as follows:
plot tree_age aging
The plot shows in the "Results" window (upper right sub window) showing "tree_age" positively related to "aging". To print the plot on the lab printer, select the plot (diagonally drag the mouse pointer across the whole plot until it  highlights -- changes color relative to its normal display), right click, and click copy.  Having gotten the plot in the clipboard, you open Microsoft  Word and set the text font so that the characters have the same width  ("courier new" will do fine) and the font size 8; then  paste, and print from Microsoft Word.   Note:  the same width characters are necessary so that, for example, the vertical bar characters for the "Y" axis line up as a straight line. Also note: the Print Result icon in the Xstata window may seem the way to go, but unfortunately does not result in connecting to the PACLab printer.

To save your tree data, you perform this Xstata command:

save mytree.dat (or "save mytree.dat, replace"  if this is not the first save)
When you open Xstata latter on, you can resume with your tree data via this command:
use mytree.dat

Your tree data along with variable names will now show up in the Editor when you open it, as well as the names also listing in Xstata's "Variables" sub window. You can now continue processing your tree data.

III. How to Access Stats/Create Files on Stats (GoBack)
 

A. Overview (GoBack)

Briefly you access and run software on Stats by SSHing to Stats, logging in (see PACLab Tips, Section II. 8 for how in the labs), and running  Stats software: Stata, SAS, Maple, Fortran Compiler programs that you develop, etc. While logged into Stats you have access to files in your  Stats Home directory or subdirectories (subfolders) that you have created; these files get there basically four ways:

(1) By creating files on "H:"  via  PC software; since "H:" shares with Stats, these files appear in your Stats Home directory (the one that you get when you first log in Stats).
(2) By SFTPing files from another source to Stats from your PC.
(3) By running Stats software/programs that create files and by copying/moving files via Stats commands
(4) By using a Stats text editor such as Edit, VI, Xemacs, or Pico.

Much of this has been illustrated by the Fortran and Xstata examples above.

B. Accessing Stats (GoBack)

You access Stats by SSHing and logging into it; you can do this in the non X-Windows mode or X-Widows mode (again see PACLab Tips, Section II. 8 for how in the labs); you must do it in the X-Windows mode if you are going to use X-Windows products such as Stata/X-Windows (see example above, Section  II.B ), SAS/X-Windows, Maple/X-Windows, or Matlab/X-Windows. You can SSH to Stats on your own PC by going to Software.wm.edu and clicking Internet Browsers and Network Tools and then SSH Secure Shell Client to download essentially the same SSH software you use in the labs; you use it just as you do in the labs as discussed at PACLab Tips, Section II. 8.

As mentioned above, once you you SSH/log into Stats, you can run Stats software, run programs you have written, and execute Stats commands; the latter includes file managing commands to copy, move, and remove files. Section V below tells how to compile and run programs that you create (using languages like Fortran, C, etc.). Section VI tells how to run  X-Windows Math/Statistical oriented software on Stats. II above illustrates with two examples. To learn about UNIX commands and how to manage UNIX files, see VII. An Introduction to Stats Unix Commands, VIII How to Manage Your Files on Stats, and IX Stats UNIX Selected Command Summary --  all located below.

Once you are in Stats, you can get help with Stats commands via the Stats "man" command. This "man" command

man command name
gets help with the specified command (e.g., "man rm"  tells how to use the Stats "Remove File" command). This command
man software name

gets help with the specified software; it works only with some of the languages; e.g., "man f77" gets help with compiling a  Fortran source program and running the compiled results; "man gcc" gets help similarly with GNU project C and C++ compiler; "man perl" gets help with Perl; only help available for Java are for its options via the command "man gcj".

For help with X-Windows products (Stata, SAS, Matlab, and Maple), click the Help item on the products main menu after opening in X-Windows.

C. Methods for Creating Files on Stats: Details (GoBack)

(1)  By Creating Files onto "H:" (Shares Files with Stats) (GoBack)

In the labs you have access to your personal disk space on the "H:" drive; this space is also accessible on your own PC if you have access to the W & M campus network -- works for most people located on the campus; for how, go to Netstore. As mentioned in the Overview above, Stats shares "H:" drive files so that when you SHH/log into Stats (go to PACLab Tips, Section II. 8. for how), you access your "H:" drive files; this means any files you create on "H:" via PC software (file managers, text editors, spreadsheets, graphics software, etc.) are available to you on Stats.

However, as noted in the Fortran example above at I, text files created on a PC end each line with a "Carriage Return (CR)" and a line feed character; on the other hand,  text files created on Stats itself (as discussed in (3) below), end each line with only a line feed; thus Stats recognizes only linefeed characters.   Processing  files with "CR"s on Stats may or not give you problems; for example, compiling a Fortran program  with "Carriage Returns (CRs)" does not (Fortran simply ignores them);  however,  other software may give your difficulties and you then want to remove the "CR"s.  To remove them use  the UNIX utility "dos2unix" in this exemplified way:

dos2unix filewithCRs.txt > tempfile
cp tempfile filewithnoCRs.txt
where each line above is typed at the Stats command line; and where "filewithCRs" is a text file created in Microsoft Word on a PC and stored on the "H:" drive;  "tempfile" is an interim file used to catch what normally would display on the monitor if the redirection part of the "dos2unix" command ">tempfile" were not there.  The "cp" command below the "dos2unix"  puts the results in file "filewithnoCRs.txt", an alternative being the original "filewithCRs.txt" file if you prefer.  The Fortran example at I above  illustrates compiling  Fortran txt file "myprog.f" on Stats where the file  had been on "H:" via the PC and thus had "CR"s; these have no affect on the compiling, but again may create difficulties with other software.

You can create, for example,  file "rmCRs" to remove the CRs by executing this at the Stats command line:

rmCRs myprog.f
where file "rmCRs" consists of the following UNIX commands::
cp "$1" "old$1"
dos2unix "$1" > rmCRs.temp
cp rmCRs.temp "$1"
Here in addition to removing the "CR"s, this UNIX program creates a copy of the original before "CR" removal (the copy's name being  "old" + the original name).  Note: carefully test "rmCRs" before using; if you use just $1 in the above and not "$1" (i.e., leave out the the double quotes), you will lose everything but the original.

And finally, you might wish to be aware of that when you return to your PC and access a file created in Stats, that the "CR"s not longer end each line, only the linefeed characters; this is usually not a problem if editing in Microsoft Word, Word Pad, and even NotePad (the latter only Word Wrap not set, causing the text to look like one long line). If, for some reason, the absence of the "CR"s gives you difficulties, you can add them in Stats via these Stats UNIX commands:

unix2dos "$1" > addCRstemp
cp addCRstemp "$1"

If after adding the "CR"s you  edit with the Stats editor Pico instead of a PC editor, the added CRs cause no trouble, because Pico removes them when you edit, permanently leaving them out when you save; however, if you use one of the other Stats editors  (Edit, IV, or Xemacs), you don't want add the "CR"s.

And finally if you edit on the PC a file created in Stats which normally has only linefeeds and you use Microsoft Word or Word Pad , the "CR"s are added and remain after you exit the word processor (doesn't work with NotePad).

(2) By SFTPing Files from a PC to Stats (GoBack)

You can transfer files from a PC to Stats by the method of SFTPing (Safe/Secure File Transfer Protocol). For how on a PC in the labs see PACLab Tips, Appendix D; on the PC this should be done in ASCII mode for text files, Binary mode for all other files. In the labs to set the mode click Edit in the F-Secure SSH File Transfer Window, Settings, and in the Settings Box click Mode under File Transfer in the left sub window, and then either Ascii or Binary under Mode on the right and finally OK it. ASCII mode removes the "Carriage Return (CR)" characters that end PC text files, but don't end text files in Stats.

Once you have transferred a file to Stats, you use the NotePad on your PC to edit it on your PC and after saving on your PC have the option to automatically transfer the edited verstion back to Stats.

(3) By Executing Stats Software/Programs and File Commands (GoBack)

Running Stats software or programs that you have written can creates files on Stats; the two examples of II above readily illustrate this.

You can also create/remove files with Stats file commands; e.g.,  the  Stats file command "cp"  in the latter part of  the Fortran example in I above copies "fort.1" created by the Fortran program to file "myprog.dat" in this way:

cp fort.1 myprog.dat

Other commands such as "mv" moves (renames) Stats files as in this exemplified alternative for creating "myprog.dat" with the contents of "fort.1":

mv fort.1 myprog.dat

On Stats you can remove files with the "rm" command as in the following where you eliminate "fort.1" after saving its content in "myprog.dat" with the "cp" command. For more about Stats file commands and other commands, go to VII. An Introduction to Stats Unix Commands, VIII How to Manage Your Files on Stats, and IX A Stats UNIX Selected Command Summary  -- located below.

For help with Stats commands use the "man" command as illustrated here for help with the "ls" command for listing files:

man  ls

(4) By Using One of Stats's Text Editors (GoBack)

You can also use Stats text editors to create files; these include  "Edit", "VI", "Xemacs", and "Pico"; for help with "Edit" or "VI", use respective the commands "man edit" or "man vi". From here on we confine our discussion to "Xemacs" and "Pico".

"Xemacs" is  an X-Windows product and you use it similarly as any Windows text  editor  on the PC; it is however, fairly complicated and requires some learning to use;  while "Xemacs" has more features than "Pico", the latter is simpler in design and easier to learn to use; you don't ned to be in X-Windows mode to use it; for this reason "Pico" is the recommended Stats text edit. The edit command for either editor is:

editor-name filename

to edit the contents of "filename" with editor "editor-name"; e.g., "pico myprog.f" opens "pico" with the contents of "myprog.f"; similarly"xemacs myprog.f" (with Stats in X-Windows mode) opens "xemacs" with "myprog.f" .

Both "Xemacs" and "Pico" permit fullscreen editing and with both the keys "Ctrl-d" delete characters forward and the keys Delete/Backspace delete characters backwards.  "Xemacs"s  structure and use are similar  to Xstata,  another X-Windows product;   to use "Xemacs" you SSH to Stats in X-Windows mode (see PACLab Tips, Section II. 8  for how in the labs).

"Xemacs" can be handy for detecting in a file "Carriage Returns (CRs)" which  show up as Ctrl-M's in "Xemacs"; on the other hand "Pico" can be handy for editing a file with  "CR"s as they do not show and are lost forever after you do a save.

In Pico you can print its display just as you can print what displays at the SSH window (i.e., the "F-Secure SSH Client" window), as discussed in IV immediately below. You can not directly print what displays in Xemac; indirectly you can print by saving, displaying in the SSH window (e.g., the command "cat myprog.f" displays "myprog.f"'s text) and printing from their (see IV below for how).
 

IV. How to Print Stats Output (GoBack)

Many of the ways to print Stats output were covered in the two examples of II. above; we will first cover these; then we will discuss other possible methods for printing Stats output. Except where noted otherwise, it is assumed that you are on a PC in the lab; also we assume that you have accessed Stats in X-Windows mode (see PACLab Tips, Section II. 8 for how).

You may wish to print output that displays in the Stats SSH window (specifically the "F-Secure SSH Client" window); this may either result from running a program that displays its output or from displaying the contents of an output file using the Stats "cat" command. To print the display, select the part the you want to print (i.e., highlight it by dragging the mouse across), then click File (main menu of the SSH window),  Print, and then OK in the Print box. Note: in the box the "Print Selection" should be on by default, if not select it before OKing. The Fortran example (see  II.A above), illustrates  printing  the displayed output of the executed Fortran program in file "myprog.f". It also exemplifies printing the Fortran program's output text file "myprog.lst" by displaying the file's contents using the Stats command "cat myprog.lst" and following the steps for printing displayed text (again by highlighting it, clicking File, Print, and then OK).

Note: this approach works for as many pages that you can scroll your SSH window ( the limit being roughly 8 pages -- that's how many pages it displays before going on to displaying more pages, those displayed before being lost). If you can save your output in a file, you can get around this limitation,  by bringing the file up in a text editor on your PC  (e.g., Microsoft Word)  and print from there; this is easily done as the same output should shows up in your "H:" drive space since again Stats shares it's files with the "H:" drive.

Note: this approach will work OK in editors like Microsoft Word, Word Pad, WordPerfect, etc. but not in a more simpler editor like NotePad; the latter requires adding "Carriage Return (CR)" characters to end the lines (e.g., as done with the  "myprog.lst" output file in the Fortran example above); else the lines pool into one long line when they display in the editor,  most of the information going off the screen. (In NotePad this can be improved by selecting Word Wrap from the Format menu; this however still doesn't prevent showing lines run together, just not lost off the screen.) You can add "CR"s by using, for example, this command to remove them from the example "myprog.lst" output file in the Fortran example above:

unix2dos myprog.lst > temp
cp temp myprog.lst

To print the output displayed in a Window of the software itself, if it in text form and you can copy into the PC's clipboard, you simply paste into one of the PC's text editors (Microsoft Word, Word Pad, etc.) and print from there. This is illustrated with the Xstata example above at II.B, where the plot created using text characters (i.e., not a graphics plot) in the Xstata Results window is to be printed; you select it (drag mouse across), copied it (right click, then click Copy Results), then past in Microsoft Word and print on the lab printer. Here before pasting into Microsoft Word, you should first set its text font to fixed length (e.g., to "courier new") to make the characters line up vertically (to insure that the plot has things lined up right); of course if the output is only reading material -- just text to be read -- it won't matter all that much.

If the output displayed in a window of the software is text, but you can not copy into the PC's clipboard (can copy into the software's clip board, but not the PC's), you may be able to save as a text file, for example as in X-Windows/SAS; then just open in one of the PC's editors (but not in NotePad because of missing of "CR"s) and print from there. In Xstata you can't save to a text file but you can save to a Ghost Script (".ps") file by selecting what to print (in the Xstata Results window), right clicking, clicking Print Results, and in the Print box do a Print to File, specifying a ".ps" file; then on the PC bring the file up in Ghost Script and print.

On the other hand, if the output in the software window on Stats is in hi resolution, there are two basic ways that you can print what displays:

(1) Do a screen capture by pressing the PC's "Print Screen" key. This puts the image of your current  screen into the PC's clipboard, and all you have to do is paste it in an Graphics editor (Microsoft Word will do here) and print from  there. This works real well if you can maximize the software's hi resolution output window so that it takes up the entire screen, which occurs, for example,  with an  Xstata's chart window; however  SAS's Chart window can not be maximized to fullscreen, so the "stuff" bordering  the Chart window (e.g., the Task Bar) get included in the printout. Pasting the  screen capture that includes the SAS Chart window into, for example, M. Photo Editor,  permits cropping out the non Chart material and printing only the SAS chart.

(2) Save the window into a format for saving an image.  Then bring up and print from the appropriate application on your PC. Most frequently, the format available is post script (.ps) (which we have already talked about as a format for saving text files) and which you can in the labs display in Ghost View and print. To do this in Xstata or Matlab, you right click the hi resolution material,  click Save File and save as a Post Script (.ps) file; then bring it up into Ghost Script/print. In SAS you do it by clicking Export from the FILE menu, specifying  the file type and here you specify ".gif" (instead of ".ps" as the latter yields nothing when brought up in Ghost Script), saving it, and bring up in any graphics editor/viewer that reads ".gif" files (e.g., Microsoft Photo Editor).
 

Note: if you have created output on Stats and you can not access it via the "H:" drive (i.e., you can not map to "H:"on your PC), you can still print it by SFTPing to Stats, down loading the output to your PC, and printing it from there. If you don't have SFTP on your own PC, you can download it and learn how to use it on your PC via the link ftp in the Netstore Web Doc (where "Netstore." is the "H:" drive storage)


V. How to Run Programs in Fortran, C,  Perl, or Java (GoBack)
 

A. How to Compile/Run Fortran Programs (GoBack)

The Fortran example above pretty much tells how to compile and run a Fortran program; the basic command format for compiling a Fortran program is this:

F77 -o outputexecfile Fortranstatementfile

where "f77" accesses the version 77 Fortran compiler, "outputexecfile" is where you want to store the executable results ("a.out" by default) and "Fortranstatementfile" contains the Fortran source statements, its name ending in ".f";  you can use "f90" or "f95" instead of "f77" for  versions 90 and 95 respectively.

To run the compiled Fortran you just type the "outputexecfile" file name at the Stats command line preceded by "./"; the "./" direct Stats to look in your current directory for the "outputexecfile" file. Your Fortran program now starts.

You can can execute "man f77" more about the  "f77" command; for more about the "f90" or "f95" commands (versions 90/95 respectively), use "man f90" or "man f95" (either gives help with both).

To illustrate with  the Fortran example above, you can compile your program in "mypro.gf" by keying this to compile it with version 77.

f77 -o myprog.out mypro.gf

To execute the compiled results, you just key this:

./myprog.out

Note: again you add "./" to "myprog.out" to tell Stats to look in your current directory for the "myprog.out" file; otherwise Stats looks in the standard Stats system directories to find "myprog.out" (just as it does to find "f77", the version 77 Fortran compiler).

As mentioned you can also execute higher level Fortran compilers than version 77 by typing, for example,

f90 or f95 -o myprog.out mypro.gf

to compile with version 90 or 95 respectively. For more see the Fortran example at IIA above.

B. How to Compile/Run C Programs (GoBack)

The basic command format for compiling a C program is this:

cc -o outputexecfile Cstatementfile

where "outputexecfile" is the name of the file to store your compiled C program and and "Cstatementfile" is the name of the file containing your "C" program statements; the format is pretty much identical to the Fortran format in A. above, except that you specify "cc" for the C compiler instead of "f77" for the Fortran compiler and you end your statement file name with ".c" instead of ".f";  and just as with the compiled  Fortran program, you run the C compiled program by typing its "outputexecfile" name at the command line preceded by a "./" (to make Stats look in the current directory for "outputexecfile". Thus, to compile and run your C statements in file "myprog.c" you can enter this:

cc -o myCprog.out myCprog.c

and to run it you type this:

./myCprog.out

For more about compiling/running C, execute "man cc".

C. How to Run  Perl Programs (GoBack)

Perl is even easier to run than Fortran or C in that it compiles and runs in one shot; there is no interim executable file to create first and then run (we therefore just refer to running it); the basic command format for running a Perl program is this:

perl Perlstatementfile

where "Perlstatementfile" is the name of the file containing your Perl program statements and should end with the extension ".pl" or "perl" to identify the program language as "Perl". To illustrate consider this command:

perl myprog.pl

which should run your Perl statements in file "myprog.pl".

For more about running Perl, execute "man perl".

D. How to Compile/Run Java Programs (GoBack)

Compiling/running a Java program is more like doing it with a Fortran or C program, with the exception that instead of compiling into basic executable machine code, the Java program compiles into Java byte codes which Java alone can execute via a Java interpreter; the basic command format for compiling a Java program is this:
 

javac -source Javastatementfile

where "Javastatementfile" is the name of the file containing Java program statements and should end

with the extension ".j"; it should be compatible with the specified release. The compilation is stored as byte codes into a Javaclassfile which has the extension ".class"; the name part of the Javaclassfile must be defined in the Java program via a "class" statement (there can be more than one "class" statement/ therefore more than one Javaclassfile to be  executed in the next step, but we confine the discussion to  one "class"). The complied Java is then execute via a Java  interpreter, using this command format:

java Javaclassfilename

where "Javaclassfilename" is the name part of the Javaclassfile name (i.e.,  the whole Javaclassfile name minus the ".class" extension). Thus to compile Java statements in file "myprog.j", you perform this at the Stat's command line:
 

javac -source myprog.j

which creates a Java class file called myprog.class", because a "Class" statement in "myprog.j" defines a single  class called  "myprog"; to run the compelled results, you do this at the command line:

java myprog

to get Java to interpret/execute the byte codes in "myprog.class" and thus run your Java program in "myprog.j".

For a summary of the flags used with the javac or java command perform respectively the commands "javac" or "java". Although there is no documentation via the Stats "man" command, Java documentation for Sun Unix is available on-line at java.sun.com/

E. How to Continue Running a Program after Exiting Stats GoBack)

There maybe times that you prefer logging out of Stats while one of your programs is running, for example, if it is a number crunch er and may take a long time; you can do this by running your program with the "no hang up" command using this format:

nohup "command-to-run-the program" &

where "command ..." is is what you normally type to run the program and "&" runs the program in the background; the latter lets get back to the Stats command line to exit or if you wish, do other things and exit later. For example this:

nohup ./myCprog.out &

runs the above example C program (see V.B. above) in the background (note that the "./" is actually not necessary because "nohup" knows to look for "myCprog.out" in the current directory); you press the Enter key and you return to the Stats command line and can logout (exit) if you wish with the "C" program continuing its execution. When you log back into Stats, you can check the status of this program by executing this:

ps -ef|grep your-id

where "|" is the vertical bar character known as the pipe command in Stats and "your-id" is your Stats id (also your W & M id); "ps ef" by itself lists all current processes running on Stats for all users; by including the "|" command, you pipe all listed processes to the "grep your-id" command which retains only those listed with "your id", you list only your processes. In our C program example, the process associated with the above "nohup" command has "./myCprog.out" trailing its listing; this identifies the "nohup" program as still executing; it also gives its "process id" immediately after "your id"; you can use this to kill it with this command:

kill "nohup process id"

Of course if your "nohup" doesn't list to begin with, then your program has stopped running.

 

VI. How to Run Statistical/Math Software and the Mailer "Pine" (GoBack)

The software discussed here can all be run in X-Windows mode, allowing you to access windows for using  the product in a manner similar to Windows PC versions of the same software. Some of the software can be used in in non windows fashion; this includes the non windows Mailer "Pine" which is a non X-Windows program. When the Statistical/Math software runs in non windows mode you either submit a file with commands to do the processing or interactively issue commands to perform the work  -- but again this is in non X-Widows mode with non of the conveniences of a typical windows product.

To run in X-Windows mode you SHH/log into Stats; then set the X-Windowing by running X-Win32; in the labs you do this by clicking Internet and Communications-->X-Win32 6--> X-Win32. The X-Wins32 logo should display, then disappear, leaving a black "X" near the bottom right of your screen in line with the Task bar; this "X" signals X-Windowing enabled with the provision that X11 Tunneling has also been selected in the Stats SHH Window, automatically done in the labs; see Note below. You then issue the command to run the X-Windows product (e.g., "xstata" to run X- Windows Stata).

Note: X-Windows works only if X11 Tunneling is set either by default as in the labs or manually if non lab. Assume you are X-Windowing on your own PC which requires setting X11 Tunneling manually; assume that you have connected/logged in Stats via the SSH window "F-Secure SSH Client" (which you can download from the IT Software Repository site at software.wm.edu; here you download by clicking Internet Browser and Network Tools under Windows software and then clicking SSH Secure Shell Client); you then set X11 Tunneling manually as follows:

In the SSH window (i.e., the "F-Secure SSH Client" window), click Edit, Settings, and then in the "Settings" box on the left, click Tunneling under Profile and on the right click (check the box) for X11 Tunneling connections; finally click OK.

Because you may wish  to access  the Stats command line while still in an X-Windows application, you can run the application in the background (via for example the command "xstata&" for the Xstata application). This does not tie up the Stats command line so that you can enter other Stats commands while still accessing the X-Windows product. You can actually start more than one X-Windows application in the background and still have access to the command line; for example, in addition to executing "xstata&", you can also execute "sas&" to open X-Windows SAS in the background too; this example of running multiple X-Windows programs at the same time is just like running PC Windows programs simultaneously.

A. How to Run Stata (GoBack)

The  Stata example at II.B above pretty well tells how to run Stata in X-Windows (where by it is referred to as "Xstata"); here we also  briefly cover using Stata  in non X-Windows.  To run in X-Windows,  you access Stats in X-Windows mode by running X-Win32 either before or after accessing Stats; in the labs you do this by clicking Internet and Communications-->X-Win32 6--> X-Win32; for more see VI 2nd paragraph above.

After accessing Stats in X-Windows mode you can open/run X-Windows Stata by typing "xstata" at the Stats command line; X -Windows Stata then opens with one big window having these sub windows:

The "Results" window for displaying the output (upper right)
The  "Command Line"  window (unlabelled, bottom right -- starts with vertical cursor in upper left of the  sub window)
The "Review" window for recording what you type on the "Command Line" window
The "Variables" window for listing current variables -- those you can access after reading/entering data

From here you can get help by typing "help" at the Xstata command line or by clicking the "HELP" item on the main menu. "Xstata" Stats is pretty much identical to PC Windows/Stata, the structure of the windows, dialogue boxes somewhat varied but with the same purpose.

Although Xstata lets you do a lot by pointing and clicking (for example, create a data set via a spreadsheet like Editor), you still can (must in some cases) specify much of the basic processing via commands at the stata command line (to save/read the spreadsheet data, perform statistical work, plot/graph,  etc.).

As a statistical system, Xstata is more like X-Windows SAS discussed below, than PC Windows/SPSS in which you can do most things completely via the point/click method. X-Windows SAS  has sub windows with  purposes that  match pretty much those of Xstata's sub windows. The exception being that SAS commands are accumulated in a text Editor window and then executed upon a run prompt, while in Xstata, commands are interactively performed, one at a time; in this sense SAS is closer to PC Windows/SPSS were it to process via commands in its Syntax Text Editor, the equivalent of SAS's Editor window.

On Stats you can also run non X-Windows Stata, where you are prompted for Stata commands just as you are at the "Xstata" command line within "X-Windows Stata" itself. You do this by typing "stata" (instead of "xstata") at the Stats command line whether in X-Windows mode or not; to quit you type "exit".

In either "Xstata" or "non X-Windows Stata",  you can also specify a file containing Stata commands to execute via the "do" command using this format:

do filename
where "filename" should be the name of a text  file in the current directory containing Stata commands (one per line)  to be performed just as if entered interactively at the Stata command line; e.g., "do myprog.stata"  executes the Stata commands in file "myprog.stata" assumed in the current directory.

B. How to Run SAS (GoBack)

To  run X-Windows SAS, you SHH/log into Stats; then either before or after logging in you set X-Windows (see VI 2nd paragraph above for how) and  execute  "sas" at the Stats command line. The Display announcing SAS and it version will appear and then be replaced with the Display Manager (Abbr. DM) showing a number of windows packed together which are the equivalent to the sub windows of Xstata discussed above; a "Getting Started Tutorial" dialog box requires clicking Cancel (or Start Guide to go through the Tutorial on a SAS WEB site via Netscape); after this the DM is all yours, showing up front these windows:

The "Explorer" on the left, the "Log" at the top, and the "Program Editor" at the bottom; appearing well below is the "ToolBox: Explorer"; each acts as a separate window which can be moved about, resized, etc. Not showing at startup are the "Results", "Output", and "Session Manager" windows, each accessed by minimizing the window that covers it (e.g., minimizing "Log" window which covers "Output") or by clicking it's item on the "View" menu of any SAS window.

In the "Program Editor" window you type/run SAS statements to do all the SAS processing; the statements  can also be read from a SAS text file in your Stats account by clicking Edit, Open, etc. Statements in the same file can also be executed without opening X-Windows SAS,  using this example command at the Stats command line:

sas myprog.sas

where "myprog.sas" contains SAS statements; after execution the log and output are in files "myprog.log" and "myprog.lst" respectively; you do not have to be logged in X-Windows mode to run SAS this way. Also you don't have to be logged in Stats at all, if you run the above with the nohup "no hang up" Stats command as follows:

nohup sas myprog.sas&

where "&" puts the SAS processing in the background, leaving you at the Stats command line; when you log out, "myprog.sas" continues to run (assuming for example its a long running program). For more about nohup including how to see if your program is still running after logging back in, see above V.E. How to Continue Running a Program after Exiting Stats.

For X-Windows SAS help, click  HELP (main menu)  on most of the X-Windows SAS sub windows;  on the HELP menu, these items may be of particular interest: Using This Window, SAS Help and Documentation, and Getting Started with SAS Software; this help is available via internet Web pages displayed in Netscape.

If you have used PC Window/SAS you should be able to similarly use X-Windows SAS; for an introduction to the PC version click sas9win.

 
C. How to Run Matlab (GoBack)

As with X-Windows Stata and X-Windows SAS, to  run X-Windows Matlab, you first SSH/log in X-Windows mode (see VI 2nd paragraph for how to set X-Windowing) and   execute  "matlab" at the Stats command line; X-Windows Matlab then opens (may have to first click its icon on the PC Task Bar); what shows is one big Matlab window, within  which are these sub windows:

The "Command" sub window, taking up the entire right half, lets you execute Matlab commands, the results showing in the same window (just like at the Stats command line).

The "Current Directory" sub window, upper left, a compact file manager, lists the current directory; tabs at the bottom alternate the display between it and the "Workspace" sub window, explained next.

The "Workspace" sub window, again upper left, lists matrices you created in Matlab; from here you can select any matrix and  view/edit it; you can save selected matrices or the whole workspace, retrieve later on.

The "Command History" sub window, lower left,  logs what  you have done via Matlab commands.

Basic  processing occurs via commands in the "Command" window (creating matrices, performing math analyses on the matrices, plotting them, etc.); as mentioned above,  the "Workspace" window supports viewing/editing/saving/retrieving the  matrices.

Unlike Xstata or SAS, you can not save/retrieve/execute Matlab commands, just the data matrices; therefore, there is no "matlab commandfile" to execute a list of Matlab commands via the Stats command line.

Because X-Windows Matlab in the W & M labs (and probably also on your own PC), is slow to respond to your typing, you may wish to switch to  the lab PC Matlab version (just click Start, Programs, Statistics, Matlab7r14, and then Matlab7r14 again); you can readily shuttle your current work space with its matrices between both Matlabs.

For Matlab help, click  HELP on its main menu.

D. How to Run Maple (GoBack)

As with the X-Windows version of Stata, SAS, and  Matlab,  to  run X-Windows Maple, you first SSH//log into Stats in X-Windows mode  (see VI 2nd paragraph for how to set X-Windowing) and execute "xmaple". X-Windows Maple  opens with one big Maple window; also there may be the "Tip of the Day" showing over it, which you can close to continue. Within you can open a worksheet sub window (just click Edit then Open), of which many can be opened at one time. All your math work can be done in these sub windows using Maple commands; the sub windows can be saved any time and restored in a later sessions.

To can also run Maple in non X-windows mode; just SSH/login to Stats (in non X-Windows or X-Windows mode) and type "maple" at the Stats command line.  Non Windows Maple will open, prompting you with a ">" to enter  Maple commands interactively or to enter  "?" for  help; "quit" exits.

For X-Windows Maple help, click HELP on its  main menu.

E. How to Run/Use the "Pine" Mailer (GoBack)

The "Pine" mailer is the only internet alternative to the "MyWM" internet Mailer at W & M; should MyWM not be accessible, "Pine" might be. Although "Pine" does not have all the niceties of a Windows product with all its mouse clicking features, it is fairly easy to navigate with just keys; it does not require Stats X-Windowing, while affording most features of any typical mailer.

To access "Pine", SSH/log into Stats (X-Windowing not required) and type "pine" at the Stats command line. "Pine" will open with its main menu, asking you first to enter you mail id and password, which if satisfied lets you access the main menu; here as else where in "Pine" you navigate with keys, the "arrow" keys being the main ones to move about, the Enter key to select (rather then click) an item. Here you move up/down the menu with the up/down keys; to select an item, again you press Enter. The mouse itself plays no function (it will when clicked partially highlight an area, but otherwise has no affect).

"Pine"s main menu items are listed below along with a some remarks about each:

VII. An Introduction to Stats UNIX Commands (GoBack)
Click the above and we introduce you to basic UNIX commands on Stats; some of these are file managing commands, which are discussed in VIII.B below. For a selected command summary,  which more completely covers these commands,   go to IX. below. You can also get on-line help via the Stats "man" command via this format:
man command-name (e.g., "man ls" for help with the "ls" command for listing Stats files)
VIII. How to Manage Your Files on Stats (GoBack)

A.  File Managing via Windows Explorer when "H:" Accessible (GoBack)

When you file manage "H:" drive files with Window Explorer you are managing Stats files since Stats shares its files with "H" files. Of course to manage "H:" drive files on your PC requires your PC to be mapped to the "H:" drive which we show you next. After that in addition to showing you briefly how to manage "H" files with the Explorer, we also show you how to convert "H:" drive text files created/edited on the PC to Stats UNIX text files for use when in Stats, which although not likely, might be necessary when applied to some Stats applications.

     (1) How to Map to "H:" if Not Already (GoBack)

If you log in your PC, you may be already mapped  to "H:" (e.g., in the labs); if not,  you should be able to manually map  to "H:" via these steps if you are connected to the W & M network (likely for those in W & M offices/residential halls):

(1) Open Windows Explorer, then Tools, and then Map Network Drive.

(2) Select "H:" from the Drive pull down in the emerging window.
(3) Enter the following in the Folder text box:

\\netstore\your-user-id$

(4) Press ENTER

If this works, you should see "H:" list in your Windows Explorer (or new a Explorer window open with "H:" listed).
    (2) Using Windows Explorer to File Manage Stats (GoBack)
Using Explorer on your PC to manage your Stats files, is the same as managing any files on "H:" or any other drive on your PC;  here you should be able to readily list, rename, delete, move, copy, and print files on your local printer (we assume here you know how or can easily learn).

    (3) Converting PC Files to UNIX Files (GoBack)

When you SSH/log into to Stats, you access "H" drive files because because "H:" shares with Stats; however,  in some cases, if your files are text type and you created them on your PC as "H:" drive files, you may have to convert to the UNIX file format to use these files when in Stats; you can do this via the following two methods:
(a) Using the "dos2unix" UNIX command

You can use this "dos2unix" command to convert, for example, file "myprog.txt" (assumed created on the PC in for example Microsoft Windows); just use these Stats commands:

dos2unix myprog.txt > temp
cp temp myprog.txt
(b) Going in & out of the "pico" text editor

Using "pico" you can  convert to UNIX, e.g. file "myprog.txt", by opening "pico" with "myprog.txt" via this command:

pico myprog.txt
"Pico" then opens with "myprog.lst" on display; at this point "pico" has converted the temporary version on display;  you then save over "myprog.txt",  exit "pico", and  "myprog.txt" is now a UNIX text file.

Specifically, what both methods do is remove "Carriage Return" (CR) characters used to end text lines on the PC, but not recognized by Stats; the latter ends lines with "linefeed" characters only while the PC includes both "linefeeds" and "CR"s to end lines.

B. File Managing via Stats Commands (GoBack)

If you SSH and log into Stats (see III.B above for how), there are a number of UNIX commands that you can use to manage your Stats files which we discuss below; we asume that you are working with files in the current working directory (indicated via the Stats command "pwd"), which can be changed with the "cd" command (see 5. below). As with any Stats command you can get help with any of these file managing commands by executing  "man" followed by the command name.

Note: unless we indicate otherwise, these commands are performed in the current directory (by default your home directory "/home/your-user-id/" indicated by the command prompt when you log in).
 

(1) Listing Files with the "ls" command

"ls" lists specified files (defaults to all files) in the current directory, either just the names or if the long list "-l" flag is added,  the complete "poop" about each file (like permission codes, owner name, size, date created, and name). The general format for  "ls" is:

ls [-flags files]

where "-flags" are optional and can be, for example, again the long list "-l" flag and/or the "-F" flag  (recommended, especially when you don't specify "files");
"-F" identifies the file; thus, a trailing "/", "*",  "@", etc.   flags a file, respectively,  as directory, executable,  link, etc. You can run "man ls" to describe all the flags.  The optional "files" spec in the "ls [-flags files]" format can be file names and/or wild-card file names (e.g., "myprog.*" lists all files beginning with "myprog"). "files" defaults to all files (again within the current directory) with the except of hidden file (those prefixed with a ".", for example ".profile" an optional file for over riding your default log in Stats profile). This "ls":

 

ls myprog.txt


displays "myprog.txt" ( if it exists in the current directory); this "ls":
 

ls -l myprog.txt


displays a line of information about "myprog.txt" (again  permission codes, owner name, size, date created, and name); this "ls":

ls -l *.txt
long lists all files that end in ".txt"; see 1. thru - 3. of An Introduction to Stats UNIX Commands  for more "ls" discussion. You can execute the Stats command "man ls" for the complete "ls" command layout.

This "ls",  long lists all files (except "." hidden files) in the current directory, flagging those that are directories, executable,  links, et.:

ls -lF

And finally this "ls" does the same except hidden files are also listed because of the added "-a" flag specifying all files.

(2) Copying Files with the "cp" command

"cp" copies a file to another file or to another director (then the source can be more than one file);   the "cp" format follows:

cp [-flags] sourcefile targetfile (or targetdir)
where "-flags" might be, for example, "-i" to interact and prevent copying into an existing file (the command "man cp" describes all the flags). "sourcefile" is the name of the file to copy from;  the copy goes into the "targetfile", a single file name,  or "targetdir", a directory spec (then "sourcefile" can be multiple  files by specifying a wild card file -- e.g., "*.dat" for all ".dat" files).

For example, to copy "myprog.dat" to "myprogbackup.dat", you type this at the command line:

cp myprog.dat myprogbackup.dat
The copy will occur right away, whether or not a current "myprogbackup.dat" exists.

If on the other hand if the above example "cp" includes an "-i" interactive flag as follows:

cp -i myprog.dat myprogbackup.dat
then if "myprogbackup.dat" already exists, you are asked permission to do it before it actually copies to "myprogbackup.dat".

Examples of copying to a directory, follow:

cp myprog.dat mysubdir
cp *.dat mysubdir
The first example, copies "myprog.dat" to directory "mysubdir"; the second copies all files with the extension "dat" to  "mysubdir" directory -- in both cases  "mysubdir" is assumed to be a sub directory to the current one (again assumed here to be your home directory "/home/userid", the default when you log in).

If you wish to copy from another account (e.g., someone in your in class if you are a student), you must add the path to the source file name, exemplified as follows:

cp /home/another-user-id/class.dat class.dat
where here "class.dat" is copied from the home directory "/home/another-user-id" to your current directory (assuming you have permissions to copy "class.dat" from  "/home/another-user-id/").

(3) Moving (Renaming) files with the "mv" command

"mv" moves a file to another file (effectively renaming it) or file(s) to a directory (actually moving file(s)); the  format for "mv" follows:

mv -flags sourcefile(s) targetfile (or targetdir)
where flags can be, for example, "-i" to ask if OK when moving to an existing targetfile (use the "man mv"command to describe all flags); examples follow:
mv myprog.txt myprog.f       (moves -- renames--   "myprog.txt" to "myprog.f')
mv myprog.* mydir             (moves -- actually moves --  all "myprog.*" files to directory "mydir")

(4) Creating Directories/Changing Directories with the "mydir"/ "cd" Commands

If you wish to create a sub directory to the current directory (again by default your home directory "/home/your-user-id"), you can use the "mydir" command with this format:

mydir your_newsubdir
where "your_newsubdir" is the name of your new sub directory. To change directories --make another directory current (e.g., change to the newly created directory), you  use the "cd" command with this format:
cd your_newsubdir
where "your_newsubdir" is the name of the directory sub to the current directory; "your_newsubdir"  now becomes current.

To exemplify, consider this, where the current directory is assumed to be your home directory "/home/your-user-id/":

mkdir my_newsubdir
here "my_newsubdir" is created as a sub directory of "/home/your- id" ; to copy, for example, file "myprog.dat" in " /home/your-user-id" to your new sub directory,  you can use this command:
cp myprog.dat my_newsubdir
To make "my_newsubdir" the current directory, you can use the "cd" command as follows:
cd my_newsubdir
At this point assume your have another sub directory to your home directory; call it "my_newsubdir2" and that you wish to make it the current one. You can do it this way in parts:
cd /home/your-user-id
cd my_newsubdir2
where the first "cd" makes your home directory current and the second requires only "my_newsubdir2", just as it did when making "my_newsubdir" current. Or you can do it this way:
cd  /home/your-user-id/my_newsubdir2
which specifies the exact path and does it in one step. Or this way:
cd ../my_newsubdir2
the same as the previous, except that you can use the parent directory symbol "../" instead of  "/home/your-user-id" since home is parent to "my_newsubdir2".

(5) Deleting Files/Directories with the "rm"/"rmdir" commands

"rm" removes file(s) and directories.  "rmdir" removes empty directories; i.e., it removes directory files and thus the names themselves, but not the directory contents; that can be done with "rm". The format for using "rm" to delete files follows:

rm [flags]

files where "flags" is optional and might be, for example, "-i" to interact and ask if it is OK to remove the specified file(s) (use  "man rm" to  describe all flags); files can be one or more file names/and or wildcard specifications (e.g., "*.lst" to remove all files that end in ".lst"). This "rm":

rm myprog.lst
removes "myprog.lst", no questions asked and no remarks if "myprog.lst" is not write protected (no permission to write) from you, the owner; because we don't recommend your changing file permissions (to for example, write protect a file), we don't show you how. One of the ways to avoid accidentally removing a file that you want to keep is to use the "-i" interaction flag which forces Stats to ask if it is OK to remove the given file before actually killing it. For example this command:
rm  -i *.lst
asks one at a time if it is OK to remove each ".lst" file before doing it. For more about recommended ways against losing Stats files inadvertently with the "rm", see Section 1 of An Introduction to Stats UNIX Commands

The format for using "rm" to delete directories and their contents, including sub directories, follows:

rm -r[f] directory
where "-r" empowers "rm" to remove directories as well as files, prompting for a "y" to OK removing each  protected file and directory; "f"  (optional) removes write protected files without prompting if OK (write protected directories and their sub directories still require an OK). Note: the term "directories" here refers to sub directories of the current directory.

To illustrate deleting directories, consider this "rm" command:

rm -r mydir

Here all files and sub directories of "mydir" are loss except those protected, then only if  you respond with  "y" when asked if OK to remove. This "rm":

rm -rf mydir

does the same, except you are not quizzed if OK to delete each protected file. This is a dangerous command! Although adding the "f" option does not eliminate protected directories/subdirectories without you giving the OK, we don't show you how to write protect files/directories so the "-rf" flag is indeed dangerous! Fortunately you can request an older backup version of lost Stats file(s)/directories(s) via E-Mail to "support@wm.edu".

Finally, you can delete empty directories with the "rmdir" command using this format:

rmdir directories
Thus if your directory "mydir" (sub directory to the current one) is empty, directory "mydir" is removed (kills the directory file that represents it):
rmdir mydir
This is by far the safest, files and sub directories within "mydir" can't be loss via this command; hence,  this example will not work (you get an error message) if at least one file/sub directory exists  in "mydir".

.

IX. Stats UNIX Selected Command Summary (GoBack)

Click above and you get additional coverage of the Stats commands beyond  the introduction in VII above and discussion of the file managing commands in VIII.B above; in table form, the  "Stats UNIX Selected Command Summary" succinctly gives you a summary about each command including example(s). Of course you always have at the Stats command line, use of the "man command-name" Stats command which  gives you every little thing about using a Stats command (e.g., "man ls" for details about the "ls" command) .
 
 

Appendix A

The Fortran Example Program

I. The Fortran Program Listed (GoBack)

C     Fortran program to display the averages of Age, Income,
C     and Education read from from terminal input
      real n, meanage, meaninc, meaned
      n=0
      sumage=0
      suminc=0
      sumed=0
      print *,
     *"Enter one case for age, income, and education (all 0's quits)."
10    read( *, *) age,income, ed
      write(1,*) age, income, ed
      if (age .eq. 0) go to 20
      n=n+1.0
      sumage=sumage+age
      suminc=suminc+income
      sumed=sumed+ed
      go to 10
20    meanage=sumage/n
      meaninc=suminc/n
      meaned=sumed/n
      print *,"Variable       age   income  education"
      print 100, meanage, meaninc, meaned
100   format(" mean    ",f10.2,f9.2,f11.2)
      end
 
 II. Creating and Saving the Fortran Program with WordPad in the Labs

To create/save the above example Fortran program in the Labs it is recommended that you use WordPad or NotePad; Microsoft Word has characters incompatible with Stats; for example the single quote in Microsoft Word comes out a different single quote when seen by Stats Fortran, creating a compiler error. We now discuss using WordPad; here the recommended font is Courier New; this produces typewriter like characters which line up from line to line, making it easy to judge what columns are being used. When you save the program in WordPad you first save it in "myprog.txt", text type; however because the extension needs to be "f" instead "txt" to make it a Fortran type file, you need to rename it to "myprog.f"; this seems best done by opening the "Save as" again which now lists "myprog.txt" and renaming it to"myprog.f"; then double click it to save in "myprog.f". From here on no renaming should be necessary, future saves will automatically save in "myprog.f" as a text file.

If you are doing this on your own PC and can not access "H:" Netstore disk storage because you are off campus, you can access your "H:" files via SFTP (to down load SFTP and learn how to use it on your PC, click sftp at Netstore); you can now access your files on Stats (because it shares with Netstore), yet still edit them on your own PC via NotePad; in the right window of your SFTP window, list "myprog.f" and then double click; a temp version will come up in NotePad; after editing it, do a save and and afterwards SFTP will show a File Modified message box; click yes and it will upload it to Stats so you can continue with the new edited version on Stats (Note: you may have to minimize NotePad to see the message box).

 

**********************************************************************************************************************   If  you have any questions/problems with this "W & M Stats User's Guide" document, please send e-mail to "jrdaws@wm.edu". or -->click here to create/send the e-mail message