escapeshellarg problem
Posted: Mon Dec 01, 2008 5:38 am
Hi all,
I am trying to pass information from a php script as an argument to a shell script which in turn writes the text to a file, so a simple transfer of text.
I am using the escapeshellarg function to make sure I have single quotes around my string and to make sure nothing goes wrong BUT it seems like escapeshellarg is doing more than I want it to do.
If I try to pass a simple string like this accross
My shell script shows the string to be missing two of the backslashes like this
"abcd \\ defg ////"
I thought this might be a problem with my shell script, but if I simply do an echo in php, I see that its php thats messing with my string
echo $arg; -->> shows "abcd \\ defg ////" on screen also.
Where are the two backslashes going and how can I stop php doing anything other than making the string safe as regards quotes (that is, don't get rid of any characters on me).
Regards,
I am trying to pass information from a php script as an argument to a shell script which in turn writes the text to a file, so a simple transfer of text.
I am using the escapeshellarg function to make sure I have single quotes around my string and to make sure nothing goes wrong BUT it seems like escapeshellarg is doing more than I want it to do.
If I try to pass a simple string like this accross
Code: Select all
$value="abcd \\\\ defg ////";
$arg=escapeshellarg($value);
$Shell_Command=$HOME."/scripts/write_file.sh " . $arg;
shell_exec($Shell_Command);
"abcd \\ defg ////"
I thought this might be a problem with my shell script, but if I simply do an echo in php, I see that its php thats messing with my string
echo $arg; -->> shows "abcd \\ defg ////" on screen also.
Where are the two backslashes going and how can I stop php doing anything other than making the string safe as regards quotes (that is, don't get rid of any characters on me).
Regards,