Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working in router development which is Ubuntu machine. In my code im trying to execute a curl command using system function but the system always returning -1 even though curl command got success. I observed this issue coming when my router wan ip changed. I see for any curl command in this case, system returning -1.

Could you please help me how to solve this?

What I have tried:

ret = system("curl --url myURL --trace-ascii /tmp/log.trace >/dev/null 2>&1")

if(ret == -1)
printf("system failed.....\n");

but my trace file contains 200 successful
Posted
Updated 23-Feb-22 22:24pm

1 solution

A return value of -1 indicates that the exit status of the curl command could not be captured. See system(3) - Linux manual page[^] for full details.
 
Share this answer
 
Comments
Member 13740197 24-Feb-22 8:57am    
Thanks for the reply Richard.
I have checked the man page and found below one to get exit status.
WEXITSTATUS(ret);
But in my case it is getting 255, how can we find root cause, based on this value?
Richard MacCutchan 24-Feb-22 9:21am    
255 is the same as -1. But I really do not know what you are doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900