System() in Arduino

Hello! I want to use the system() function. I notice that I don’t get any errors when calling system() and passing in parameters like “pwd” or “ls”. However, the output of the function is always -1. I am not sure where I am going wrong.

Does the ardiuno not support this? My code is basically:

Serial.print(system(" pwd"));

Thanks!

system() is a a C library function from Unix that allows the code to invoke an executable stored on disk (where else would they be stored). It's the basis for a command shell (an executable) that allows it to invoke other executables.

since there is no disk with other commands, invoking system() will no doubt fail with a -1 return code.

Thanks for the update! I thought it would work considering I don't get any errors, and system() even lights up in orange.

and system() even lights up in orange.

The Arduino IDE colour highlighting functionality is a waste of time.

apk190000:
I thought it would work considering I don't get any errors, and system() even lights up in orange.

i guess you consider ok because you didn't get a compiler error. But it gave you a run-time error (-1)