-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmenu.c
More file actions
56 lines (44 loc) · 965 Bytes
/
Copy pathmenu.c
File metadata and controls
56 lines (44 loc) · 965 Bytes
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
# include<stdio.h>
# include<sys/types.h>
# include<unistd.h>
# include<errno.h>
# include<sys/wait.h>
#include<string.h>
void run_program(char *name)
{
char cmd[1024] = "./";
// Put path coresponding to your files
char path[1024] = "./chatsystem/programs/client/";
strcat(cmd, name);
strcat(path, name);
char *execve_argv[] = {cmd, NULL};
execve(path, execve_argv, NULL);
}
int main(int argc, char* argv[])
{
char opt;
printf("Welcome to Telemetry!\n");
printf("\nChoose one role:\n");
printf("\t1. Publisher\n");
printf("\t2. Subscriber\n");
printf("\t3. Sublisher\n");
printf("Your option: ");
scanf("%c", &opt);
if (opt == '1')
{
run_program("publisher");
}
else if (opt == '2')
{
run_program("subscriber");
}
else if (opt == '3')
{
run_program("sublisher");
}
else
{
printf("Invalid option!");
}
return 0;
}