Engineering Problem Solving II

Download Report

Transcript Engineering Problem Solving II

Intro to Programming
Environment
1
Today You Will





Learn how to connect to a machine remotely
with “nomachine NX client”
Learn how to create a new “source file” with an
editor (gedit)
Learn how to edit a perl program
Learn how to execute a program
You will learn some basic Linux commands
2
Background

Our development platform of choice is Linux
(specifically Open Suse)
http://en.opensuse.org (if you are curious)
 Our interpretor of choice is perl
http://www.perl.org/ (if you are curious)

Why do we have to use Linux when
XP/MacOSX/Vista/Sun is the best OS and Bill
Gates/Steven Jobs/Scott MacNealy is the
smartest/richest person in the world?
3
Linux

Reasons for using Linux:





Open source means we have access to every line
of code
Open source means we have control over the OS
Cost
Uniform platform (that way when you write your
program on Linux and you get it to work, the TA can
run it on Linux and it will also work)
The college of engineering is currently supporting
this platform
4
For subsequent connections, you
only need to use the “NX Client
for Windows”
The FIRST time you connect, you
will use the “NX Connection
Wizard”
5
6
7
8
Check this box if you want a
Shortcut created on your desktop
9
10
11
Click to
close
annoying
“Useful
Tips”
12
Click here to
Open menu
13
Click on Applications
then
Utilities
Scroll down: HINT – if you don’t get the
scroll bar – you can just use the “arrow
down” on the keyboard.
Click on
“Utilities”
14
Select “Editor”
15
Select “Text Editor
gedit”
16
Now we have a screen in
which we can type in a
program
17
Type in one of the world’s simplest
programs
18
File -> Save AS…
19
Type in file name – hello.c
The “dot-c” is a convention
to specify that this is actually
Enter file name: a “C” source file
Note – the procedure for
saving files in discussion
will be slightly more
complicated – the TA’s
will cover that in
discussion
20
Does your program “look”
any different now?
21
Now select “Applications” -->
“System”  “Terminal”  “Terminal
Program Konsole”
22
Your screen will look something
like this.
23
ls – command lists all files/directories
Note the “hello.pl” file
Also – you are likely to have
different files in your account
(my directory is a mess and
should probably be “cleaned
up.”)
24
perl hello.pl -- this executes your source
code
25
Unix and Linux basics:








ls – list files and directories
perl – invoke the interpreter
gedit – start our editor from the command line
mkdir dir1 – make a directory with the name “dir1” (aka called
folders by Windows and Mac users)
cd dir1 – navigate down one directory level to “dir1”
cd .. – move up one level in a directory structure
rm hello.pl – this will permanently remove the file “hello.pl”
CAUTION – once you do this – there is NO getting your file back
(you can also rm a directory once it is empty of files)
There is also a way to rm multiple directories/files – but maybe
we’ll show that at a later time
26
Navigating a File System

Students tend to be more comfortable
navigating a file system with Windows
because of the graphical representation
 Ex.) My Computer  (C:) Local Disk 
Documents and Settings , etc….
 However, the concept is the same with Linux
 cd My Computer/Local Disk/Documents and
Settings
 You can navigate “down” (or up) multiple
levels with “cd”
27
Your CSS account and “home”

All CSS accounts have a “home”
directory
cd – without any parameters always takes
you to your “home” directory
Note that if you perform
 pwd – print working directory ‘pwd’ before you ‘cd’, you

$ cd
$ pwd
/usr/eng/tbraun
$ pwd
/nfs/server00/local/vol00/t/b/tbraun
will see a “strange’ home
directory – this has to do
with how the drives are
shared across the
network. These are in fact
the same directory. After
you ‘cd’ – you will always
see /usr/eng/tbraun
28
Making a directory, and
traversing
mkdir EPS2
cd EPS2
mkdir hw1
cd hw1
gedit hw1.pl (save and quit)
cd
cd EPS2/hw1
cd ..
29
ENDING your session
After you click the little red
button below – after a few
seconds, this entire window
will close.
To end your connection – click this little red
button
30
Connecting from off-campus
You may download and install the “NX
client” from virtually any machine
including PC, Macs, and Linux
http://www.nomachine.com/download.php

Select “NX Client for Windows” if you are
using Windows, etc.
31
Other ways of doing things
You should play around with the
desktop.
 You will find there are multiple ways to
navigate (try My Computer -> My Home
Folder)
