1 / 24

CS 590 Programming Environments with UNIX

CS 590 Programming Environments with UNIX. Computer Lab Account www.cs.uah.edu/account Course Homepage www.cs.uah.edu/~kkeen/CS590 LASER Lab N328. Some Background. UNIX UNIX System V BSD POSIX LINUX. LASER LAB. System Names:. Remote Access.

diem
Download Presentation

CS 590 Programming Environments with UNIX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 590Programming Environments with UNIX

  2. Computer Lab Accountwww.cs.uah.edu/account • Course Homepagewww.cs.uah.edu/~kkeen/CS590 • LASER Lab N328

  3. Some Background • UNIX • UNIX System V • BSD POSIX • LINUX

  4. LASER LAB System Names:

  5. Remote Access • PuTTY is a free telnet/SSH clientYou can download PuTTY here • Upload/Download requires SFTPYou can use PSFTP to upload/download.

  6. Remote Access from UNIX/LINUX • ssh username@hostEx: 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 pagessection 1: User commandssection 2: system callssection 3: library callssection 4: special or device filessection 5: file formats and conventionssection 6: games for linuxsection 7: macro packages and conventionssection 8: system management commands

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

  10. Multi UserMulti 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 Kernel C Library App func func func func func func

  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/intro/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.

More Related