1

My code is:

char* arg_list[] = { "gnuplot", "gnuplot_script.sh", NULL };
printf("Ready %s %s\n", arg_list[0], arg_list[1]);
execv( "gnuplot", arg_list );
_exit(EXIT_FAILURE);

The output is:

Ready gnuplot gnuplot_script.sh

but nothing happens (while it should pop a graph).

I am copy-pasting the output, without "Ready " into the terminal, at the same place I just executed my program and it works. So I am not sure this is a path problem.

What I am missing?

gsamaras
  • 71,951
  • 46
  • 188
  • 305

1 Answers1

1

execv() requires a path, e.g.:

execv("/usr/bin/gnuplot", arg_list);

You can use execvp() if you just want to supply a filename:

execvp("gnuplot", arg_list);

Both functions set errno on failure, so running perror() on failure will tell you what's going on.

Crowman
  • 25,242
  • 5
  • 48
  • 56