1 | /*****************************************************/ |
---|
2 | /* this file is part of the tiTan / tiTanNIT Project */ |
---|
3 | /* and allowed only for use with this. */ |
---|
4 | /* */ |
---|
5 | /* copyright by NIT */ |
---|
6 | /*****************************************************/ |
---|
7 | |
---|
8 | #ifndef SCRIPTEXEC_H |
---|
9 | #define SCRIPTEXEC_H |
---|
10 | |
---|
11 | void screenscriptexec() |
---|
12 | { |
---|
13 | int dirrcret = 0; |
---|
14 | char* tmpstr = NULL, *startdir = NULL; |
---|
15 | char* file = NULL, *ret = NULL; |
---|
16 | |
---|
17 | |
---|
18 | start: |
---|
19 | startdir = getconfig("scriptexecpath", NULL); |
---|
20 | |
---|
21 | tmpstr = ostrcat(file, "", 1, 0); file = NULL; |
---|
22 | file = screendir(startdir, "*.sh", basename(tmpstr), &dirrcret, NULL, _("BG-RUN"), getrcconfigint("rcred", NULL), NULL, 0, NULL, 0, NULL, 0, 90, 1, 90, 1, 2); |
---|
23 | free(tmpstr); tmpstr = NULL; |
---|
24 | |
---|
25 | if(file != NULL && (dirrcret == 0 || dirrcret == 1)) |
---|
26 | { |
---|
27 | if(dirrcret == 0) |
---|
28 | { |
---|
29 | tmpstr = ostrcat(file, " 2>&1", 0, 0); |
---|
30 | ret = command(tmpstr); |
---|
31 | free(tmpstr); tmpstr = NULL; |
---|
32 | } |
---|
33 | if(dirrcret == 1) |
---|
34 | { |
---|
35 | tmpstr = ostrcat(file, " &", 0, 0); |
---|
36 | system(tmpstr); |
---|
37 | free(tmpstr); tmpstr = NULL; |
---|
38 | } |
---|
39 | |
---|
40 | if(ret == NULL) ret = ostrcat(_("Script has no output or started in background."), NULL, 0, 0); |
---|
41 | textbox(_("Script execute"), ret, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 600, 0, 0); |
---|
42 | free(ret); ret = NULL; |
---|
43 | goto start; |
---|
44 | } |
---|
45 | |
---|
46 | free(file); |
---|
47 | } |
---|
48 | |
---|
49 | #endif |
---|