cgs 3460 why we choose unix n powerful lmulti-user operating system lgood programming tools most...
TRANSCRIPT
CGS 3460
Why we choose UNIXWhy we choose UNIX Powerful
Multi-user operating system Good programming tools
• Most heavy-duty database management systems started out on Unix
Flexible Thousands of tools that can be combined and recombined.
Reliable Unix is hard to crash.
CGS 3460
How to Access a UNIX MachineHow to Access a UNIX Machine
Your personal computer
(client)
rain.cise.ufl.edu
(server)
telnet / ftp
telnet: allows you to connect to other computers and use softwares thereftp: allows you to retrieve files from other computers.
CGS 3460
TelnetTelnet TELetype NETwork
A network protocol used on the Internet / LAN
By extension, refers to the program which provides the client part of the protocol
Once connected Log on as a regular user with access to
• application / software• data
A Telnet command request looks like this telnet rain.cise.ufl.edu
CGS 3460
FTPFTP File Transfer Protocol
A network protocol used on the Internet / LAN Allow to transfer files to and from remote computers
A ftp command request looks like this ftp rain.cise.ufl.edu
CGS 3460
SSHSSH Why SSH
Figures from http://www.suso.org/docs/shell/ssh.sdf
Download SSH http://www.openssh.org/
CGS 3460
More about SSHMore about SSH Recommendation for Windows
Putty as telnet tool• http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
WinSCP as ftp tool• http://winscp.net/eng/download.php
Other choices ftp, telnet using command line in windows Other softwares
• Core FTP
http://www.coreftp.com/download.html
CGS 3460
Unix CommandsUnix Commands man – manual (man gcc) ls – list directory contents (ls) pwd – prints working directory (pwd) cd – change directory (cd <subdirectory>) mkdir – create directory (mkdir <new directory> rm – remove a file (rm <file to remove>)
Use –r if removing a directory
CGS 3460
Unix Commands(cont)Unix Commands(cont) cp–copy a file (cp <source><destination>)
Use –r if copying a directory mv–move or rename files (mv <source> <destination>) jpico – text editor (jpico <file to edit>) gcc – compiler (gcc sourceFile.c)
-o option Directory shortcuts
~ home directory .. parent directory . sub directory
CGS 3460
Your First ProgramYour First Program#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
Preprocessor: interact with input/output of your computer
You will see this at the beginning of nearly all programs
Tells computer to load file named <stdio.h>
<stdio.h> allows standard input/output operations
CGS 3460
Your First ProgramYour First Program#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
Start point of the program
Preprocessor: interact with input/output of your computer
C programs contain one or more functions, exactly one of which must be main
int means that the function main will "return" an integer value
CGS 3460
Your First ProgramYour First Program#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
Start point of the program
Preprocessor: interact with input/output of your computer
Start and finish of function
CGS 3460
Your First ProgramYour First Program#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
} Printing a line of Text
Start point of the program
Preprocessor: interact with input/output of your computer
Start and finish of function
CGS 3460
Your First ProgramYour First Program#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
} Printing a line of Text
Start point of the program
Preprocessor: interact with input/output of your computer
Start and finish of function
New line character
CGS 3460
Your First ProgramYour First Program#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
} Printing a line of Text
Start point of the program
Preprocessor: interact with input/output of your computer
Start and finish of function
Finish and return value 0
A way to exit a function
It means that the program terminated normally in this case
CGS 3460
Comments for programsComments for programs Why need comments
Good habit Readable to others Remind yourself
How to comment /* … */ // …
Effects on compiler Examples
CGS 3460
CompilerCompiler What is compiler
A computer program (or set of programs) that translates text written in a computer language ( the source code) into another computer language (most time the executable file)
Why we need a compiler Available C compiler in UNIX system: gcc
gcc sourcefile.c –o exefile.exe
CGS 3460
Text EditorsText Editors Edit your code Using wordpad, or some text editor on
your personal computer Need to transfer your program to UNIX machine using ftp
Edit your code in UNIX using vi pico (jpico) emacs
CGS 3460
ProcedureProcedure
This is your C program. Type the code in any standard text editor, and save it as helloworld.c. Transfer it to rain.cise.ufl.edu if necessary
#include <stdio.h> int main() { printf("Hello World\n"); return 0; }
helloworld.c
C-compilerType gcc helloworld.c –o helloworld.exe
to compile helloworld.c into helloworld.exe using the gcc compiler
0011 0000 1010 01101100 0110 1011 01011010 1110 0110 1110
helloworld.exe The gcc compiler generates corresponding executable code named helloworld.exe. The computer can execute this machine readable code if you type ./helloworld.exe