thanks,it works
bin.w...@qkmtech.com From: Chris Johns Date: 2018-06-22 13:07 To: bin.w...@qkmtech.com; Users Subject: Re: how to use system function to execute the script On 22/06/2018 14:44, bin.w...@qkmtech.com wrote: > hi everyone: > > i want to use the "system()" to execute the script. but do not has output > > first i want to use "system()" to execute the shell cmd, but alse have no > output > > the test code is as followed: > > system("ls -l"); > system("joel /flash/script/spdloop_1"); // > "/flash/script/spdloop_1"----------this is the script file path in the > filesystem > RTEMS is a single address space, single process OS so you can not exec another process. You can call the shell command handler from any thread. Make sure you have enough stack for the thread. Try something like: int run_shell_command(const char* cmd) { #define CMD_MAX_ARGS (20) char* cmd_argv = strdup(cmd); int argc; char* argv[CMD_MAX_ARGS]; int r; if (cmd_argv == NULL) { fprintf(stderr, "shell: command: no memory: %s", cmd); return 1; } if (rtems_shell_make_args(cmd_argv, &argc, argv, CMD_MAX_ARGS) < 0) { fprintf(stderr, "shell: command: arg parse: %s", cmd); free(cmd_argv); return 1; } r = rtems_shell_execute_cmd(argv[0], argc, argv); free(cmd_argv); return r; } Chris
_______________________________________________ users mailing list users@rtems.org http://lists.rtems.org/mailman/listinfo/users