180 likes | 299 Views
Why 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. Your personal computer (client).
E N D
Why 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.
Your personal computer (client) rain.cise.ufl.edu (server) How to Access a UNIX Machine telnet / ftp telnet: allows you to connect to other computers and use softwares there ftp: allows you to retrieve files from other computers.
Telnet • 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
FTP • 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
SSH • Why SSH • Download SSH • http://www.openssh.org/ Figures from http://www.suso.org/docs/shell/ssh.sdf
More 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
Unix 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
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
Your First Program Preprocessor: interactwith input/output of your computer #include <stdio.h> int main() { printf("Hello World\n"); return 0; } 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
Your First Program Preprocessor: interactwith input/output of your computer #include <stdio.h> int main() { printf("Hello World\n"); return 0; } Start point of the program • 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
Your First Program Preprocessor: interactwith input/output of your computer #include <stdio.h> int main() { printf("Hello World\n"); return 0; } Start point of the program Start and finish of function
Your First Program Preprocessor: interactwith input/output of your computer #include <stdio.h> int main() { printf("Hello World\n"); return 0; } Start point of the program Start and finish of function Printing a line of Text
New line character Your First Program Preprocessor: interactwith input/output of your computer #include <stdio.h> int main() { printf("Hello World\n"); return 0; } Start point of the program Start and finish of function Printing a line of Text
Your First Program Preprocessor: interact with input/output of your computer #include <stdio.h> int main() { printf("Hello World\n"); return 0; } Start point of the program Start and finish of function Printing a line of Text Finish and return value 0 • A way to exit a function • It means that the program terminated normally in this case
Comments for programs • Why need comments • Good habit • Readable to others • Remind yourself • How to comment • /* … */ • // … • Effects on compiler • Examples
Compiler • 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
Text 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
helloworld.c #include <stdio.h> int main() { printf("Hello World\n"); return 0; } C-compiler helloworld.exe 0011 0000 1010 0110 1100 0110 1011 0101 1010 1110 0110 1110 Procedure 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 Type gcc helloworld.c –o helloworld.exe to compile helloworld.c into helloworld.exe using the gcc compiler The gcc compiler generates corresponding executable code named helloworld.exe. The computer can execute this machine readable code if you type ./helloworld.exe