質問

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

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

役に立ちましたか?

解決 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)

他のヒント

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).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top