Both sides previous revision
Poprzednia wersja
Nowa wersja
|
Poprzednia wersja
|
pl:dydaktyka:unix:lab_prog_system [2014/01/12 15:42] kkluza [Ćwiczenie: Środowisko pracy procesu] |
pl:dydaktyka:unix:lab_prog_system [2019/06/27 15:50] (aktualna) |
====== Elementy programowania systemowego w środowisku Unix ====== | ====== Elementy programowania systemowego w środowisku Unix ====== |
===== DO PRZYGOTOWANIA ===== | |
* [[http://home.agh.edu.pl/~gjn/dydaktyka/UGLX/node10.html|Kompilacja programów w środowisku Unix]] | |
| |
| <code> |
| better !pout !cry |
| better watchout |
| lpr why |
| santa claus town |
| |
| cat /etc/passwd >list |
| ncheck list |
| ncheck list |
| cat list | grep naughty >nogiftlist |
| cat list | grep nice >giftlist |
| santa claus town |
| |
| who | grep sleeping |
| who | grep awake |
| who | egrep 'bad|good' |
| for (goodness sake) { |
| be good |
| } |
| |
| /* Nadesłał: Jakub Pelczar, IS 2012 */ |
| </code> |
| |
| ===== DO PRZYGOTOWANIA ===== |
| * Proszę przypomnieć sobie, w jaki sposób kompiluje się programy w języku C w środowisku Unix \\ (np. [[http://home.agh.edu.pl/~gjn/dydaktyka/UGLX/node10.html|Kompilacja programów w środowisku Unix]]). |
| * Proszę przejrzeć manual do funkcji systemowych: **''open(2)''**, **''creat(2)''**, **''read(2)''**, **''write(2)''**, **''stat(2)''**, **''close(2)''**, \\ jak również manuale do funkcji: **''getenv(3)''**, **''putenv(3)''**, **''setenv(3)''** oraz do zmiennych: **''errno(3)''**, **''environ(7)''**. |
===== WPROWADZENIE ===== | ===== WPROWADZENIE ===== |
| |
| |
Program //f1.c//: | Program //f1.c//: |
<code c> | <code c f1.c> |
#include <stdio.h> | #include <stdio.h> |
#include <fcntl.h> | #include <fcntl.h> |
Program //f2.c//: | Program //f2.c//: |
| |
<code c> | <code c f2.c> |
#include <stdio.h> | #include <stdio.h> |
#include <fcntl.h> | #include <fcntl.h> |
* funkcje z 1. programu, | * funkcje z 1. programu, |
* możliwość zadania innego trybu dostępu do pliku, | * możliwość zadania innego trybu dostępu do pliku, |
* możliwość kopiowania dowolnej długości danych, | * możliwość kopiowania pliku dowolnej długości. |
| |
==== Ćwiczenie: Podstawowe operacje na katalogach ==== | ==== Ćwiczenie: Podstawowe operacje na katalogach ==== |
Program //d2.c//: | Program //d2.c//: |
| |
<code c> | <code c d2.c> |
#include <stdio.h> | #include <stdio.h> |
#include <string.h> | #include <string.h> |
Program //p1.c//: | Program //p1.c//: |
| |
<code c file p1.c> | <code c p1.c> |
#include <stdio.h> | #include <stdio.h> |
#include <unistd.h> | #include <unistd.h> |
Program //p2.c//: | Program //p2.c//: |
| |
<code c> | <code c p2.c> |
#include <stdio.h> | #include <stdio.h> |
#include <unistd.h> | #include <unistd.h> |
Jaka jest różnica pomiędzy funkcjami //system()// a //exec()//? | Jaka jest różnica pomiędzy funkcjami //system()// a //exec()//? |
| |
Proszę zmodyfikować program tak, używają innych wywołań //exec()//. | Proszę zmodyfikować program tak, aby działał tak samo przy użyciu innych wywołań z rodziny funkcji //exec()//. |
| |
Proszę oglądnąć i uruchomić poniższy program. | Proszę oglądnąć i uruchomić poniższy program. |
Program //p3.c//: | Program //p3.c//: |
| |
<code c> | <code c p3.c> |
#include <stdio.h> | #include <stdio.h> |
#include <unistd.h> | #include <unistd.h> |
Program //p4.c//: | Program //p4.c//: |
| |
<code c> | <code c p4.c> |
#include <stdio.h> | #include <stdio.h> |
#include <unistd.h> | #include <unistd.h> |
Program //p5.c//: | Program //p5.c//: |
| |
<code c> | <code c p5.c> |
#include <stdio.h> | #include <stdio.h> |
#include <unistd.h> | #include <unistd.h> |
Program //p6.c//: | Program //p6.c//: |
| |
<code c> | <code c p6.c> |
#include <stdio.h> | #include <stdio.h> |
#include <unistd.h> | #include <unistd.h> |
Program //p7.c//: | Program //p7.c//: |
| |
<code c> | <code c p7.c> |
#include <stdio.h> | #include <stdio.h> |
#include <unistd.h> | #include <unistd.h> |