obrien obrien - 6 months ago 44
PHP Question

php shell_exec echo

I'm working on interfacing a microcontroller with a lamp server. I am trying to run the command

echo -e -n "data \r" > /dev/ttyUSB0
using shell_exec in php but with no results. It works just fine from the command line. Doing a little experimenting, I discovered that
echo -e -n "1 \r"
actually echoes
-e -n 1
. Is there a reason it won't take the -e or -n options?
Here's my code:

shell_exec('echo -e -n "1 \r" > /dev/ttyUSB0');


Instead of using shell_exec and echo, why not use PHP's filesystem functions?

file_put_contents('/dev/ttyUSB0', "1 \r");