Hello! There is a console program Mystem, I try to run it on a Linux server and process the data, but the feeling that the program itself does not start, how to make sure that it starts? Sample code below:

$text = "Любимый мой хитер темпераментный кидать книги"; function mystem($q) { $result = exec ('echo "'.$q.'" | /mystem/mystem_3_linux_3 -w '); // $result = preg_replace ("/[\?\}\{]/"," ",$result); return $result; } $texts = explode(" ", $text); foreach ($texts as $answer => $keys) { echo $answer ."=". mystem($keys); echo "<br/>"; } 

I’ll add a Linux server to me, I’d like to determine if the program starts exactly and why it doesn’t give any data.

  • Make a conclusion. How do you run? - Naumov
  • echo "Favorite" | / mystem / mystem_3_linux_3 -i 0 = 1 echo "my" | / mystem / mystem_3_linux_3 -i 1 = 1 echo "cunning" | / mystem / mystem_3_linux_3 -i 2 = 1 echo "temperamental" | / mystem / mystem_3_linux_3 -i 3 = 1 echo "throw" | t / mystem / mystem_3_linux_3 -i 5 = 1 echo "books" | / mystem / mystem_3_linux_3 -i 6 = 1 - sanitarn

1 answer 1

 $errorCode = null; $result = exec ('echo "'.$q.'" | /mystem/mystem_3_linux_3 -w 2>/tmp/out.txt 1>/tmp/out.txt' , $errorCode); var_dump($errorCode); 

if the console command generates output, it will be written to /tmp/out.txt (if you have write permissions) Also, the return code will be written to the $ errorCode variable. null - did not work at all, 0 - everything worked fine, any other value is an error during execution.

  • The file was just empty, maybe I am doing something wrong based on the documentation? tech.yandex.ru/mystem/doc/index-docpage - sanitarn
  • if the file is created, then the command itself starts. What's in the return code? - rjhdby
  • the file was not created, I created it, after it was erased, launched, looked at the hosting, there is no this file. The output on the page is array (0) {} - sanitarn
  • If exec with 2>/tmp/out.txt 1>/tmp/out.txt file is not created, then there are three options 1) the script does not have permissions to write to / tmp, then change to the folder where it is exactly can write, 2) mystem_3_linux_3 does not return anything to standard streams, try running the command from the shell and see the output, 3) the command is not executed. Check if php has the right to run this file - rjhdby
  • Launched from the shell yadi.sk/i/mXY2hfLyxxAWy Segmentation fault 0 = <br/> Segmentation fault - sanitarn