By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

PHP and command line (for Wiki)

P: n/a
Ale
Hi... I started to "program" in PHP (better say to read it :P) from a
few days because I am installing a Wiki on a virtual server (Windows
Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.

However, I am trying to parse latex equations and encountered some
troubles. I have already installed all the necessary software and when
I execute the following by command line:

C:\miktex\bin\latex.exe --output-directory=C:\Inetpub\vhosts\mysite.com
\httpdocs\wiki\images\\tmp\\ --interaction=nonstopmode C:\a.tex

I generate the right file in the right folder. However, when I try to
execute (adding it to a PHP routine that is executed for sure):

$command = "C:\miktex\bin\latex.exe --output-directory=C:\Inetpub
\vhosts\mysite.com\httpdocs\wiki\images\\tmp\\ --
interaction=nonstopmode C:\a.tex";
$text = exec($command);

it doesn't happen anything. Permissions in tmp should be fine... do
you have any suggestion?

Thanks
Ale

Jul 2 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Ale wrote:
Hi... I started to "program" in PHP (better say to read it :P) from a
few days because I am installing a Wiki on a virtual server (Windows
Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.

However, I am trying to parse latex equations and encountered some
troubles. I have already installed all the necessary software and when
I execute the following by command line:

C:\miktex\bin\latex.exe --output-directory=C:\Inetpub\vhosts\mysite.com
\httpdocs\wiki\images\\tmp\\ --interaction=nonstopmode C:\a.tex

I generate the right file in the right folder. However, when I try to
execute (adding it to a PHP routine that is executed for sure):

$command = "C:\miktex\bin\latex.exe --output-directory=C:\Inetpub
\vhosts\mysite.com\httpdocs\wiki\images\\tmp\\ --
interaction=nonstopmode C:\a.tex";
$text = exec($command);

it doesn't happen anything. Permissions in tmp should be fine... do
you have any suggestion?

Thanks
Ale
Add 2>&1 to your command and look what it says (make use of exec's
second param)
--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Jul 2 '07 #2

P: n/a
Ale
Hi - I simplified the code at the maximum and wrote:

<?php

$fp = fopen(".\f.tex","a+");
fputs($fp,'s_1');
fclose($fp);
echo exec('2>&1; latex .\a.tex');

?>

f.tex is written in the same folder where the PHP page is executed,
showing that I have the proper permissions on the folder. When I
execute

latex .\a.tex

from shell, where a.tex is a properly formatted latex source, all work
fine.
However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
attended results, not giving any output file. It returns the message
"operable program or batch file".

I really have no idea what is wrong :(

Cheers,
Ale

Jul 2 '07 #3

P: n/a
Ale wrote:
Hi... I started to "program" in PHP (better say to read it :P) from a
few days because I am installing a Wiki on a virtual server (Windows
Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.

However, I am trying to parse latex equations and encountered some
troubles. I have already installed all the necessary software and when
I execute the following by command line:

C:\miktex\bin\latex.exe --output-directory=C:\Inetpub\vhosts\mysite.com
\httpdocs\wiki\images\\tmp\\ --interaction=nonstopmode C:\a.tex

I generate the right file in the right folder. However, when I try to
execute (adding it to a PHP routine that is executed for sure):

$command = "C:\miktex\bin\latex.exe --output-directory=C:\Inetpub
\vhosts\mysite.com\httpdocs\wiki\images\\tmp\\ --
interaction=nonstopmode C:\a.tex";
$text = exec($command);

it doesn't happen anything. Permissions in tmp should be fine... do
you have any suggestion?

Thanks
Ale
'\' is the PHP escape character. Either use '\\' instead, or use
forward slashes ('/') instead.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 2 '07 #4

P: n/a
Ale
On Jul 3, 12:37 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Ale wrote:
Hi... I started to "program" in PHP (better say to read it :P) from a
few days because I am installing a Wiki on a virtual server (Windows
Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.
However, I am trying to parse latex equations and encountered some
troubles. I have already installed all the necessary software and when
I execute the following by command line:
C:\miktex\bin\latex.exe --output-directory=C:\Inetpub\vhosts\mysite.com
\httpdocs\wiki\images\\tmp\\ --interaction=nonstopmode C:\a.tex
I generate the right file in the right folder. However, when I try to
execute (adding it to a PHP routine that is executed for sure):
$command = "C:\miktex\bin\latex.exe --output-directory=C:\Inetpub
\vhosts\mysite.com\httpdocs\wiki\images\\tmp\\ --
interaction=nonstopmode C:\a.tex";
$text = exec($command);
it doesn't happen anything. Permissions in tmp should be fine... do
you have any suggestion?
Thanks
Ale

'\' is the PHP escape character. Either use '\\' instead, or use
forward slashes ('/') instead.

the fopen code was working also in with the back slash... however
thanks for the suggestion. In any case, latex is still not compiling
the files when called by PHP...

Cheers

Jul 3 '07 #5

P: n/a
Ale wrote:
Hi - I simplified the code at the maximum and wrote:

<?php

$fp = fopen(".\f.tex","a+");
fputs($fp,'s_1');
fclose($fp);
echo exec('2>&1; latex .\a.tex');

?>

f.tex is written in the same folder where the PHP page is executed,
showing that I have the proper permissions on the folder. When I
execute

latex .\a.tex

from shell, where a.tex is a properly formatted latex source, all work
fine.
However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
attended results, not giving any output file. It returns the message
"operable program or batch file".

I really have no idea what is wrong :(

Cheers,
Ale
Maybe your webserver user doesn't have the authority to execute your
latex command.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 3 '07 #6

P: n/a
Ale
unfortunately I checked and that is not the problem... both for
cmd.exe and latex.exe.
As a matter of fact I get this message "operable program or batch
file" and not access denied as was happening before I solved this
issue (I think)

Ale wrote:
Hi - I simplified the code at the maximum and wrote:
<?php
$fp = fopen(".\f.tex","a+");
fputs($fp,'s_1');
fclose($fp);
echo exec('2>&1; latex .\a.tex');
?>
f.tex is written in the same folder where the PHP page is executed,
showing that I have the proper permissions on the folder. When I
execute
latex .\a.tex
from shell, where a.tex is a properly formatted latex source, all work
fine.
However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
attended results, not giving any output file. It returns the message
"operable program or batch file".
I really have no idea what is wrong :(
Cheers,
Ale

Maybe your webserver user doesn't have the authority to execute your
latex command.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Jul 3 '07 #7

P: n/a
Ale wrote:
unfortunately I checked and that is not the problem... both for
cmd.exe and latex.exe.
As a matter of fact I get this message "operable program or batch
file" and not access denied as was happening before I solved this
issue (I think)

>Ale wrote:
>>Hi - I simplified the code at the maximum and wrote:
<?php
$fp = fopen(".\f.tex","a+");
fputs($fp,'s_1');
fclose($fp);
echo exec('2>&1; latex .\a.tex');
?>
f.tex is written in the same folder where the PHP page is executed,
showing that I have the proper permissions on the folder. When I
execute
latex .\a.tex
from shell, where a.tex is a properly formatted latex source, all work
fine.
However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
attended results, not giving any output file. It returns the message
"operable program or batch file".
I really have no idea what is wrong :(
Cheers,
Ale
Maybe your webserver user doesn't have the authority to execute your
latex command.

It sounds like it's trying to say something like "not an operable
program or batch file". It can still occur if the directory is
inaccessible.

Check your security for the file and directory. Ensure your webserver
user has read authority on the directory and read and execute on the file.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 3 '07 #8

P: n/a
On 03.07.2007 01:32 Ale wrote:
Hi - I simplified the code at the maximum and wrote:

<?php

$fp = fopen(".\f.tex","a+");
fputs($fp,'s_1');
fclose($fp);
echo exec('2>&1; latex .\a.tex');

?>

f.tex is written in the same folder where the PHP page is executed,
showing that I have the proper permissions on the folder. When I
execute

latex .\a.tex

from shell, where a.tex is a properly formatted latex source, all work
fine.
However, "echo exec('2>&1; latex .\a.tex'); " does not provide the
attended results, not giving any output file. It returns the message
"operable program or batch file".

I really have no idea what is wrong :(

Cheers,
Ale
2>& goes after command, not before it:

exec('latex .\a.tex 2>&1', $output);
print_r($output);
--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Jul 3 '07 #9

P: n/a
Ale
Hi... er.... thank you for insisting on that line! :)

I checked all permission and where ok... at least on the latex.exe
file, while I had to manage adequately the access to the parent
folder. Not the simple code is working and I think I will be able to
build the rest of the php code on the top of that.

THANKS

Ale

Jul 3 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.