-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStd_Shell.c
More file actions
82 lines (66 loc) · 1.83 KB
/
Copy pathStd_Shell.c
File metadata and controls
82 lines (66 loc) · 1.83 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
void Error(char* msg) {
perror(msg);
exit(1);
}
int main(int argc ,char* argv[]) {
//////////////////////// Initializing ///////////////
char scan[100];
char*args[3];
int ids;
memset(scan, 0, sizeof(scan));
////////////////// student funcs /////////////////////
while(1==1){
printf("StdShell> ");
scanf("%s",scan);
if (strcmp(scan,"ShowCourses")==0){
if ( ( ids = fork() ) == 0 ) {
execl("/home/braude/ShowCourses","ShowCourses",0);
Error("failed execl ShowCourses\n");
}
wait();
}
else if (strcmp(scan,"GetNewCourse")==0){
if ( ( ids = fork() ) == 0 ) {
execl("/home/braude/GetNewCourse","GetNewCourse",0);
Error("failed execl GetNewCourse\n");
}
wait();
}
else if (strcmp(scan,"MakeSchedule")==0){
if ( ( ids = fork() ) == 0 ) {
args[0]="/home/braude/MakeSchedule";
args[1]=argv[1];
args[2]=NULL;
execv("/home/braude/MakeSchedule",args);
Error("failed execl MakeSchedule\n");
}
wait();
}
else if (strcmp(scan,"GetSchedule")==0){
if ( ( ids = fork() ) == 0 ) {
args[0]="/home/braude/GetSchedule";
args[1]=argv[1];
args[2]=NULL;
execv("/home/braude/GetSchedule",args);
Error("failed execl GetSchedule\n");
}
wait();
}
else if (strcmp(scan,"LogOut")==0){
execv("/home/braude/LogOut",NULL);
Error("failed execv LogOut\n");
}
else
printf("Not Supported\n");
memset(scan, 0, sizeof(scan));
}
////////////////////// close and clean //////////////////////////////
return 0;
}