Skip to content
Snippets Groups Projects
Commit 3fcd7f78 authored by cprutean's avatar cprutean
Browse files

Upload New File

parent 4d76fbd0
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
tt When developing programs in Linux it is easier to use the Terminal
window rather than windows interface, to do this either:
1. click on the Terminal icon in the lower menu-bar, or,
2. from the Menu select the Terminal icon from the left hand column of
icons.
This will create a Terminal or Command Line window into which you can
type commands.
webonly
Old fashioned This looks like a very *old-fashioned* way to use a
computer, but it gives you an easier interface and by typing commands to
get to understand what you are *really* doing.
Almost all programmers use the simple command interface, it is therefore
worth doing and the best place for novice programmers to start. It is
also the basis of the Jupyter-Notebook environment which is based on
command lines,
Programmer is large scale projets frequenctly use an Indegrated
Development Environment (IDE) for example PyCharm or Eclipse. These give
an windows programming environment with integrated editor, debugger,
code checker and code version management system. There are useful, but
there is a signifiacnt overhead in learning to use the IDE which for
novice programmers obscures the actually programming task so in this
course we shall use:
The Linux file system is a *tree* as shown below:
It is divided into two parts, the *system* under the node and the *user*
files under the node.
hone Under you each have directory (or folder) called
/Home/s\<yyxxxxx>
where is your username. This is your directory and where you start when
you start the file browser or create a Terminal.
All files in your directory and in the tree below belong to you, you can
create, move, copy and delete files as you wish. They are private to you
so cannot be read or modified by other users.
webonly
You can navigate your part of the file system starting from your
directory with the file browser as on any windows interface, but you
will need to so this from the Terminal Window.
Here the important commands are:
- $\hookleftarrow$ will shown the *<u>p</u>resent <u>w</u>orking
<u>d</u>irectory*, so the directory that the Terminal Window is
looking at.
- $\hookleftarrow$ will *<u>l</u>i<u>s</u>t* the files in the *present
working director*
more information The command $\hookleftarrow$ will give you a *long
list* with more details about each file.
- $\hookleftarrow$ which will *<u>c</u>hange <u>d</u>irectory* into
the new directory .
- $\hookleftarrow$ will *move up* to the directory above.
- $\hookleftarrow$ will create a *<u>m</u>a<u>k</u>e a
<u>directory</u>* with the specified name.
You should *play* wth these commands and make youself a sensible
directory structure and ensure you can *move about* in in without
getting lost.
Remember to type $\hookleftarrow$ (the return key) after every command
to execte it.
Once you have started create file there are also a range of useful
commands to manipulate files, these are
- $\hookleftarrow$ will type the contents of the file to the screen
*screen at a time*, press for the next screen, to *quit*.
- $\hookleftarrow$ will make a *<u>c</u>o<u>p</u>y* od called
- $\hookleftarrow$ will *<u>m</u>o<u>v</u>e* to , so it does a
*rename*
- $\hookleftarrow$ will *<u>r</u>e<u>m</u>ove* or *delete* .
**Note:** if you , is *really gone*, there is no safety *Trash
Basket* that you can fish your mistakes out-off, so *be careful!*
webonly
terse and obscure Yes Terminal commands are terse and obscure, but once
you have learnt them it is the fastest way to access your computer…you
are really learning a scripting language and once you do this you will
see the benefit.
This is the way that progarmmers *actually* use their machines!
To delete a files in a Windows system you have to
1. find the file(s) in the window,
2. click on them and drag it to the *Trash Basket*
3. empty the *Teash basket*…,
In the Terminal your type and it is *gone* and *really gone*.
The process you will follow to develop your programs is:
- Write the code is a text editor, here we will use `emacs`,
- save the code to a file,
- run the code from the command line,
- update code in the editor as require and re-save,
- re-run from the command line
To edit the file you type in the Terminal Window
emacs MyProgram.py &
followed the Return, the $\hookleftarrow$ key.
1. The filename *must* have a extension, this tells the system and the
editor that is contains code.
2. If the file exits, it will be edited, if not a new blank file will
be created.
3. The is *essential*, it means run the editor in a new separate window
in the *background* so you can type additional commands to the
Terminal Window
4. Note the command will *not* be executed intil you type Return
To run the program you type in the Terminal Window:
python3 MyProgram.py
again followed by Return, the $\hookleftarrow$ key.
This will run the program, it will prompt you for any input you have
asked for via the calls in , display any output from statements, and
also from the *Traceback* if your program crashed, see
- Download the programs from
- run the program with $\hookleftarrow$
- Edit the program and *personalise it* by making in your name. (You
should be able to guess what to edit).
Well done, you have just written you *first* program!!
save Remember when you re-edit the file (to fix a bug!) you **MUST** do
a *Save Buffer* in to save the new version to disc before you try and
re-run the program.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment