Frage

I downloaded wget from gnuwin32 and I am trying to run the command in a c++ program using the system() function. I am using visual studio 2012 on a windows OS as my compiler. wget runs on the command line but does not run when I put it in the system function. My error is " 'wget' is not recognized as an internal or external command,operable program or batch file"

Here is my code:

#include <cstdlib>
#include <iostream>
#include <string>


using namespace std;

int main()
{
string str = string("wget -O test.csv \"http://")+"somewebsitelink\"";

    const char *x = str.c_str();
    cout << str << endl;
    system(x);

system("pause");

return 0;

}
War es hilfreich?

Lösung

Visual Studio is probably overriding your normal path somehow if it really is in the path and not working.

Just put the full path in manually:

system("c:/path/wget ...");

Andere Tipps

wget needs have its directory in the list of directories in your PATH environment variable.

Since you are using Windows, you'll have to modify it your user configuration. It has been years since I have used windows, so I no longer recall exactly where it is.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top