php shell_exec() through cygwin
-
03-07-2019 - |
Question
I wrote a script that compiles LaTeX code through pdftex
. The trouble is that pdftex
only runs on linux.
I am accomplishing this task with the use of shell_exec()
.
I don’t really have the ability to set up a linux box as a web server. I have my client computer, but it is behind a firewall that I do not control. I do have control of my work server which is running SBS 2003 with a Windows 2000 virtual machine running apache and php. To my knowledge, you can’t install pdftex
in Windows, and if you could it wouldn’t work with shell_exec()
.
Is there way to work around this with cygwin? I could install pdftex in cygwin, and then configure php to run shell_exec()
commands inside of cygwin. If this is possible, could somebody point me in the right direction?
Also, I wonder if there is another course of action. I wouldn’t mind buying hosting, but any shared hosting plan isn’t going to support the app. It would have to be a virtual or dedicated hosting plan; something I can’t afford.
Solution
pdfTeX runs just fine on Windows, without requiring Cygwin. Try MiKTeX.
OTHER TIPS
For anyone who is wondering about running shell_exec()
through Cygwin, check out this link to a comment in the PHP manual:
http://us.php.net/manual/en/function.shell-exec.php#68647
$result = shell_exec("C:\cygwin\bin\bash.exe --login -c '/cygdrive/c/cygwin/bin/convert.exe --version'");
The key is the "--login" option which appends all the required common cygwin binary and library paths to $PATH. Without this option some of the cygwin binaries that links to other libraries ( Like ImageMagick binaries which links to X11 ) will not work and you may see errors like "cygX11-6.dll not found, Could not start convert.exe"