0

I have xx file into ubuntu machine and I trying to access this file through php script and insert plain text into it . to insert text into this file I used bash file which contain this code

 echo $1>> xx

this script will get text which wanted to be insert as parameter and insert it into xx file

to run bash file I used this code in php

      header('Content-type: text/plain') ;

           echo  $txt = 'hello \n how are you \n ';

 shell_exec ("sudo /bin/bash  /etc/freeradiusbash/append.sh  '".$txt."'"); 

I want to print hello in first line and how are you in second line but the content of xx file is

hello \n how are you \n

how can I tell bash file to print text as plain text

Muhammad
  • 101
  • 1
  • 11

2 Answers2

0
echo -e "Top line \nBottom line"
Output:  Top line
         Bottom line

Without the -e flag, the \n will be preserved as text.

0

First, change echo $1>> xx to echo "$1">> xx, then change

echo  $txt = 'hello \n how are you \n ';

to

echo  $txt = "hello \nhow are you\n";
Jahid
  • 21,542
  • 10
  • 90
  • 108