using process to create a file

Hi,

What I want to do is to create a file on my Yuns SD card using the process library.

For now I am just trying to create a file containing “this_text”. LAter this will be replaced by sensor results.

What I am trying is:

Process p;       
           p.begin("echo");
           p.addParameter("this_text > /mnt/sda1/arduino/test.txt");
           p.run();

But this just echo’s “this_text > /mnt/sda1/arduino/test.txt” instead of creating the file test.txt containing “this_text”.

I have been trying different things, but without success. I could do in some other ways, but I would prefer something simple as the above code. What am I doing wrong?

Thanks!

Piping (redirecting input/output of a process) cannot be used with addParameter If you want to use piping you need to use p.runShellCommand("echo this_text > /mnt/sda1/arduino/test.txt"); that replaces the 3 lines you wrote

Ah thanks. Good to know.

What is the reason for the existence of the {begin/addparameter/run} style of process starting on top of the runShellCommand? Can you do things with the first that you can not do with runShellCommand?

Character escaping. You wanted to echo a ">" you had to escape it. With addParameter you just type it, it's escaped for you