I want to know how can I do something like this in a C program.
if wget -q www.someurl.com;
then echo OK;
else echo Not there;
fi
fork().exec*().SIGCHLD do wait(&status).WEXITSTATUS(status) to get the equivalent to r=$? from your script.system() is highly unportable as one never knows which shell might get involved. @RussellReedI'd rather not do this through exec but through leveraging something like libcurl http://curl.haxx.se/libcurl/c/
wgetinr, not the exit code. Anyway, the proper idiom isif wget -q www.someurl.com; then echo OK; else echo Not there; fi