Pregunta

How do I execute below mentioned command using exec inside a C language program in linux?

wget -P ./Folder http://www.google.com

¿Fue útil?

Solución 2

I've find this solution for the problem and it worked in my case.

char *args[] = {"/usr/bin/wget", "-P","./Folder", "http://www.google.com", (char *) 0 };

execv("/usr/bin/wget", args);

And another solution to this is to directly run the command with system function like:

system(wget -P ./Folder http://www.google.com)

Otros consejos

execl("/usr/bin/wget", "-P", "./Folder", "http://www.google.com", NULL);

Unless you have to use exec, I suggest using system from libc, since it is more portable (in case you ever decide you want to port it).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top