문제

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;

}
도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top