0

I have a PHP code in which shell_exec command takes a word and make it as an argument to the jar file (that simply displays the argument yet). But when I echo the result for any Urdu word it displays '?????'

My jar works absolutely fine with English word, but not for any Urdu word.

My code is

   <?php
   $q="علی";
   $out="/path/to/jar/myJar.jar  $q";
   $out2=shell_exec($out);
   echo $out2;
   ?>
halfer
  • 19,824
  • 17
  • 99
  • 186
eliya
  • 99
  • 7
  • 3
    Note: Please make sure that you use [`escapeshellarg()`](http://php.net/manual/en/function.escapeshellarg.php) when using *any* user input in the shell! Otherwise, look forward to `; sudo rm -rf /`, and have your entire server be gone. – h2ooooooo Dec 02 '14 at 12:07
  • if you run `/path/to/jar/myJar.jar علی` on the command line of the server, does it work? also try running something like `/bin/echo علی > /tmp/test.out` in the shell_exec and see what is getting passed to the shell. (Just trying to narrow down where the problem is) – Doon Dec 02 '14 at 12:16
  • @Doon yes it works fine on the command line of the server. shell_exec is having some issue. – eliya Dec 04 '14 at 03:33
  • You need to set the LANG env var first. See also http://stackoverflow.com/questions/10028925/call-a-program-via-shell-exec-with-utf-8-text-input – symcbean Feb 01 '16 at 00:02

0 Answers0