Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 590 Programming Environments with UNIX. Computer Lab Account www.cs.uah.edu/account www.cs.uah.edu/account Course Homepage www.cs.uah.edu/~kkeen/CS590.

Similar presentations


Presentation on theme: "CS 590 Programming Environments with UNIX. Computer Lab Account www.cs.uah.edu/account www.cs.uah.edu/account Course Homepage www.cs.uah.edu/~kkeen/CS590."— Presentation transcript:

1 CS 590 Programming Environments with UNIX

2 Computer Lab Account www.cs.uah.edu/account www.cs.uah.edu/account Course Homepage www.cs.uah.edu/~kkeen/CS590 www.cs.uah.edu/~kkeen/CS590 LASER Lab N328

3 Some Background UNIX UNIX System V BSD POSIX LINUX

4 LASER LAB System Names: catalinaconquestcrusader dakotaduchesshavoc hawkerinvaderlightning maraudershrikewhirlwind

5 Remote Access PuTTY is a free telnet/SSH client You can download PuTTY herehere Upload/Download requires SFTP You can use PSFTP to upload/download.

6 Remote Access from UNIX/LINUX ssh username@host Ex: ssh kkeen@havoc.cs.uah.edu

7 What you are expected to already know bash and simple shell operations Files and directories File structure /... Absolute vs. relative paths File and directory permissions File and directory commands cp, mv, scp (secure copy), rm, mkdir, rmdir, tar Set up environment variables PATH, LD_LIBRARY_PATH At least one text editor vi, emacs, pico Strong C programming skills

8 Getting Help The man pages section 1: User commands section 2: system calls section 3: library calls section 4: special or device files section 5: file formats and conventions section 6: games for linux section 7: macro packages and conventions section 8: system management commands

9 UNIX/LINUX System Overview Apps Shell Kernel H.W. System call interface

10 Multi User Multi Process system Every user has a UID Every user belongs to at least one UNIX group GID Root always has UID of 0

11 Programs and Processes A program is an executable file A process is an executing instance of a program

12 Kernel Mode vs. User Mode User mode Most apps run in this mode Kernel mode “trusted” code

13 System Calls App C Library func Kernel

14 System Call Error Handling For most system calls, return values are: 0 – success Negative number – failure errno perror strerror

15 perror void perror (const char *msg); Prints the text in msg followed by a colon and text description of the error number.

16 perror example FILE *myFile; myFile = fopen(“file.txt”, “r”); if(myFile == NULL) { perror(“unable to open file”); }

17 strerror char *strerror(int errnum); Prints out text for given error number. Can be used as part of a larger error message.

18 strerror example FILE *myFile; myFile = fopen(“file.txt”, “r”); if(myFile == NULL) { fprintf(stderr, “unable to open file: %s”, strerror(errno)); }

19 Basic IPC - Signals Inter Process Communication (IPC). Most basic form is via signals. Used to notify a process of some condition. We can catch signals and Ignore them Let default action take place Call a custom signal handler

20 Example Program Files and Directories http://www.cs.uah.edu/~kkeen/CS590/examples/intr o/pseudols http://www.cs.uah.edu/~kkeen/CS590/examples/intr o/pseudols More about files and directories in chapter 4

21 Time in UNIX Historically Calendar Time Process Time Clock Time User CPU Time System CPU Time

22 Command Line Arguments int main(int argc, char** argv) int main(int argc, char *argv[]) argc – argument count argv – array of character pointers Dealing with numbers atoi atof

23 getopt int getopt(int argc, char* const argv[], const char *optstring); Function to allow easy parsing of command line options Looks for options we specify Sets optarg and optind Can specify required argument by using ‘:’ after the option in optstring

24 getopt_long Uses two dashes instead of one Allows longer, more descriptive options.


Download ppt "CS 590 Programming Environments with UNIX. Computer Lab Account www.cs.uah.edu/account www.cs.uah.edu/account Course Homepage www.cs.uah.edu/~kkeen/CS590."

Similar presentations


Ads by Google