-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathSaraVargasTerminal.c
63 lines (57 loc) · 2.19 KB
/
SaraVargasTerminal.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <stdlib.h>
int main() {
pid_t pid;
int n;
do{
printf("\nWelcome to cat terminal!\n");
printf("\nMENU:\n[1] See my files\n[2] Where am I?\n[3] See the date\n[4] See this year's calendar\n[5] Exit");
printf("\nEnter your choice: ");
scanf("%d", &n);
printf("\n");
switch(n){
case 1:
pid = fork();
if(pid == 0){
execlp("/bin/ls","ls",NULL);
}else{
wait(NULL);
}
break;
case 2:
pid = fork();
if(pid == 0){
execlp("/bin/pwd","pwd",NULL);
}else{
wait(NULL);
}
break;
case 3:
pid = fork();
if(pid == 0){
execlp("/bin/date","date",NULL);
}else{
wait(NULL);
}
break;
case 4:
pid = fork();
if(pid == 0){
execlp("/bin/cal","cal",NULL);
}else{
wait(NULL);
}
break;
case 5:
printf("Exiting...\n");
break;
default:
printf("Write a proper option");
}
}while(n!=5);
return 0;
}