Micah Cowan wrote: > On 06/23/2010 03:14 AM, Chitra Nanda wrote: > >> Hi, >> >> I want to know if I can call wget programmatically from c/c++ program. I >> don't want to use system(wget). That will >> cause portability issues for me. I would need that to work on all platforms. >> > system() is portable to all platforms: it is a part of the C and C++ > standards, and is in fact the only portable way to do as you request. > However, it doesn't provide you with the output that came from wget > (directly; you could redirect to a file and parse that), and blocks > until wget is finished. This may make it less desirable for you to use, > in which case you'll most likely have to write an interface yourself > that does what you want, and implement it using platform-specific code > on whichever platforms you wish to support. > popen() is also portable. However, both system() and popen() can give portability issues escaping input. Although in case of escaping just a url for wget, you can enclose it in double quotes (to escape ampersands) and %-escape any other shell-sensitive character.
Chitra Nanda: > I want the same piece of code to work on vmware environment in addition to > all the other platforms. > In vmware Hypervisor environment there is no support for system(), so I will > not be able to use the same. > Does it only allow one process? Vmware and hypervisor are not terms too specific. Is it a hardware hypervisor controlling the server?
