Read Linux executable return value on sketch

Hi.

I am using Process in order to run a Linux executable file from my sketch and it already works but that file has an output that I would like to get in my sketch.

If I run my executable file passing parameters and using echo $?, I am able to see the return value in Putty:

/mnt/sda1# ./myexecutable 96.3 85.2 74.1; echo $? The output is an integer that I use as a flag that indicates the result obtained by the executable file, in this case I get a 69.
Now I need to get this output in my sketch, actually I have this code in my sketch:

  Process p2;
  String R;
  p2.begin("/mnt/sda1/myexecutable");

  p2.addParameter("13.9");
  p2.addParameter("13.8");
  p2.addParameter("13.7");

  p2.run();

    while (p2.running()){};
    while (p2.available()) 
    {
      R += p2.readString(); 
    }
    SerialUSB.print(F("RAz : "));
    SerialUSB.println (R);

It actually works but in this way I am not able to get any answer form my executable. Is it possible?

Try to add the echo command to the command string you pass the Process object. Or write a script that runs your executable and echos the return value, and then call that from your Process object. Or, if you write the executable, have it print it's output to STDOUT, rather than as a return status.

The Process object returns the executable's STDOUT output stream from the process, not the final return value. Similarly, when you write to the Process object, the executable gets it as STDIN. Reading/writing a Process object passes STDIN/STDOUT, not parameters or returned status values.