curl command not recognized while call from system() or popen() in c

  • Thread starter Thread starter HarishDev
  • Start date Start date
H

HarishDev

Guest
trying to call cURL from a .exe using both system and popen command, but it shows like "curl not recognized as internal or external command" error. I have put the curl code directly in a .bat file and its working fine. I have written the .exe file in C. The .exe working fine in one of the system but not on others.

working fine when directly called through command prompt or .bat file

this is my code

char second_cmd[128];
char psBuffer[128];

memset(psBuffer,
'\0', 128);
memset(second_cmd,
'\0', 128);

strcpy(second_cmd,
"curl -v -d \"Testing upload#Name=Sarad#CSP=HP
Laptop#\" -k POST http://example.com/api.php");

if( (pPipe = _popen( second_cmd, "rt" )) == NULL )
exit(
1);
memset(psBuffer,
'\0', 128);
printf(
"\n");
while(fgets(psBuffer, 128, pPipe))
{
printf(psBuffer);
memset(psBuffer,
'\0', 128);
}

//ret = system(second_cmd); //not working too.`


Continue reading...
 
Back
Top