CSC212 Lab 8 2014

From dftwiki3
Revision as of 15:07, 15 October 2014 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- <br /> <bluebox> This lab is about programming shell scripts, using redirection, pipes, for-loops and various shell tools. </bluebox> <br /> =Connect to Linux= <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut (talk) 15:07, 15 October 2014 (EDT)



This lab is about programming shell scripts, using redirection, pipes, for-loops and various shell tools.


Connect to Linux


  • Connect to your 212a account on one of the Linux Mint machines, or, using your laptop, directly to beowulf2. If beowulf2 is unresponsive, you can connect from your laptop to any of these IP addresses, which belong to our Linux Mint machines in FH342 and FH345. In this case you should replace beowulf2.csc.smith.edu by a group of 4 numbers separated by dots. Note that this machine must be ON and have Linux booted and running before you can actually connect to it. You can connect to amachine even if somebody else is using it, or is already connected to it.

This section is only visible to computers located at Smith College


Redirection


  • Every command, every program in the Linux operating system reads data from the standard-input, and outputs information to the standard-output and the standard-error. By default the standard-input, or sdin for short, is attached to the keyboard.

By default, the standard-output (stdout for short) and the standard-error (stderr for short) are connected to the display.

  • Here is a short Java program that outputs to both stdout and stderr:


public class Demo1 {
	public static void main(String[] args) {
		System.out.println( "This goes to stdout" );
		System.err.println( "This goes to stderr" );
	}
}
Note the different streams used to pring: System.out and System.err.
  • Run the program in the Terminal