0

I have linux sed command in php but it consider \t as tab in TDL\=c:\tdl\Main.tcp

shell_exec("sudo sed -i '/User\ TDL=Yes/a TDL\=c\:\\tdl\\Main.tcp' /home/"$loginuser"/."$loginuser"/drive_c/Program\ Files/Tally.ERP9/tally.ini");

please how to solved in php

my original linux command is

sudo sed -i '/User\ TDL=Yes/a TDL=c\:\\tdl\\Main.tcp' /home/"$loginuser"/."$loginuser"/drive_c/Program\ Files/Tally.ERP9/tally.ini
LOKESH
  • 1,303
  • 1
  • 16
  • 29
  • which is your orginal linux command that you wanna run without PHP, please post the command. Remeber inside double quote \t or \n will be evaluate but inside single quote it will be treated as string. – BetaDev Apr 28 '17 at 05:21
  • 3
    Possible duplicate of [What is the difference between single-quoted and double-quoted strings in PHP?](http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – John V. Apr 28 '17 at 05:22

1 Answers1

0

for your tab problem use one more back slash. instead of \tdl use \\tdl.

But I think your command is also wrong. Please post linux command directly so that I can correct it. But for tab problem put one extra back slash that will treat your \t as a string not a tab.

Anyway, according to your command, see following that how to ingore \t as being treated as tab

echo "sudo sed -i '/User\ TDL=Yes/a TDL=c\:\\tdl\Main.tcp' /home/your_loginuser/your_loginuser/drive_c/Program\ Files/Tally.ERP9/tally.ini";

Here in your case:

$loginuser = "xyz";
echo "sudo sed -i '/User\ TDL=Yes/a TDL=c\:\\tdl\Main.tcp' /home/$loginuser/".$loginuser."/drive_c/Program\ Files/Tally.ERP9/tally.ini";
BetaDev
  • 4,516
  • 3
  • 21
  • 47