Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't execute external program through system()?

I tried to compile my latex file in php script, but it can't call xelatex.

In php script:

system("/usr/bin/whoami");
system("/usr/bin/xelatex foo.tex 2>&1");

output:

myuser
sh: 1: /usr/bin/xelatex: not found

But in my terminal:

$ /usr/bin/whoami
=> myuser
$ /usr/bin/xelatex foo.tex
This is XeTeX, Version 3.1415926-2.2-0.9995.2 (TeX Live 2009/Debian)
...(successful output)...

I run php as myuser, and pass system() absolute path. And I turn safe_mode off. Why can't I still execute external programs?

like image 940
Lai Yu-Hsuan Avatar asked Nov 13 '22 08:11

Lai Yu-Hsuan


1 Answers

Finally I contacted my system administrator and found the problem. The machine is in a NFS, so the apache and login shell is on different machines. There is no xelatex on the machine where apache is running.

like image 134
Lai Yu-Hsuan Avatar answered Nov 16 '22 02:11

Lai Yu-Hsuan