Printing backslashes in exec ()

I figured out how to print \on a page using the echo command using

echo '\\';

This happens when used inside a function exec(). I am trying to issue this command on the command line to run csvkit:

csvclean -q \" -e ascii  -z 10000000000000 file.csv

Unfortunately, I need to specify "to specify my variable. I believe that be that as it may, "slipping away properly, but nothing helps me print \.

This is what I tried:

exec("csvclean -q \" -e ascii  -z 10000000000000" . " " . $csvfilename );
+4
source share
2 answers

As requested, in the form of an answer. ^^

Since you need both \"literally in exec, you can do one of two things:

exec("csvclean -q \\\" -e ascii  -z 10000000000000 " . $csvfilename );

, , .

exec('csvclean -q \" -e ascii -z 10000000000000 ' . $csvfilename );
0

addslashes :

echo addslashes('csvclean -q " -e ascii  -z 10000000000000 file.csv');

:

csvclean -q \" -e ascii -z 10000000000000 file.csv

Edit:

:

exec('csvclean -q \" -e ascii -z 10000000000000 ' . $csvfilename );
+6

Source: https://habr.com/ru/post/1619805/


All Articles