I'm actually trying to "create" a script file (like script.sh) with php.
I get phone number by php request on previous page.
I got the script working in runscript but i need it to be "dynamic", so here is a part of my script working in bash :
$tel = 34000000000
echo "\"OK\"" > /script_minicom/script_$tel
echo "send AT+CMGS=\"+$tel\" \r" >> /script_minicom/script_$tel
Here is the output :
"OK"
send AT+CMGS="+34000000000" \r
Name of the file
/script_minicom/script_34000000000
But i need it working with PHP (to get phone number) so i'm trying this :
$tel = $_POST['tel'];
exec("echo '\"OK\"' > /script_minicom/script_$tel");
exec("echo send AT+CMGS=\"+$tel\" '\r' >> /script_minicom/script_$tel");
It works for the first line but the 2nd make my "\r" disapear and $tel isn't surrounded by quotes (can't work wihtout them) :
"OK"
send AT+CMGS=+34000000000
Name of the file :
/script_minicom/script_34000000000
\r
inside double quotes gets interpolated as a carriage return in PHP. Use single quotes around it
exec("echo send AT+CMGS=\"+$tel" .'" \r'. " >> /script_minicom/script_$tel");
Output
send AT+CMGS="+34000000000" \r