Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7252 > unrolled thread

How to run a batch file using PHP?

Started byFastian <abdulbasit.fast@gmail.com>
First post2012-10-03 21:17 -0700
Last post2012-10-09 12:18 +0200
Articles 14 — 6 participants

Back to article view | Back to comp.lang.php


Contents

  How to run a batch file using PHP? Fastian <abdulbasit.fast@gmail.com> - 2012-10-03 21:17 -0700
    Re: How to run a batch file using PHP? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-10-04 09:49 +0200
      Re: How to run a batch file using PHP? Fastian <abdulbasit.fast@gmail.com> - 2012-10-04 22:21 -0700
        Re: How to run a batch file using PHP? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-10-05 09:26 +0200
          Re: How to run a batch file using PHP? Fastian <abdulbasit.fast@gmail.com> - 2012-10-05 00:55 -0700
            Re: How to run a batch file using PHP? Shake <QUITAESTO@QUITAESTO.NOES> - 2012-10-05 10:00 +0200
              Re: How to run a batch file using PHP? Fastian <abdulbasit.fast@gmail.com> - 2012-10-05 04:24 -0700
        Re: How to run a batch file using PHP? Tim Streater <timstreater@greenbee.net> - 2012-10-05 08:56 +0100
          Re: How to run a batch file using PHP? Fastian <abdulbasit.fast@gmail.com> - 2012-10-05 01:00 -0700
            Re: How to run a batch file using PHP? bill <william@TechServSys.com> - 2012-10-05 07:35 -0400
              Re: How to run a batch file using PHP? Fastian <abdulbasit.fast@gmail.com> - 2012-10-07 21:33 -0700
                Re: How to run a batch file using PHP? Fastian <abdulbasit.fast@gmail.com> - 2012-10-08 03:19 -0700
                  Re: How to run a batch file using PHP? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-10-08 15:16 +0200
                  Re: How to run a batch file using PHP? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-10-09 12:18 +0200

#7252 — How to run a batch file using PHP?

FromFastian <abdulbasit.fast@gmail.com>
Date2012-10-03 21:17 -0700
SubjectHow to run a batch file using PHP?
Message-ID<6a8001c9-b576-4b49-bbef-cef6de443c0f@googlegroups.com>
I am trying to run a batch file using exec function in PHP. The program statement executes without any error but nothing happen and batch file is not executed.

The batch file is v.simple with just two commands.This batch file runs fine when I run directly from cmd.But when I use exec function from my PHP page, I am unable to run this batch file. I am not interested in the output returned by exec( ) function's argument . I am just interested in the complete execution of the batch file.

I have also tried using the exec() in following way but not successful:

exec("c:\\windows\\system32\\cmd.exe /c $batchFileToRun"); 

Is there any option available better than exec()?
Can anyone help me?

[toc] | [next] | [standalone]


#7253

From"Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Date2012-10-04 09:49 +0200
Message-ID<k4jf2b$57o$1@dont-email.me>
In reply to#7252
El 04/10/2012 6:17, Fastian escribió/wrote:
> I am trying to run a batch file using exec function in PHP. The program statement executes without any error but nothing happen and batch file is not executed.
>
> The batch file is v.simple with just two commands.This batch file runs fine when I run directly from cmd.But when I use exec function from my PHP page, I am unable to run this batch file. I am not interested in the output returned by exec( ) function's argument . I am just interested in the complete execution of the batch file.
>
> I have also tried using the exec() in following way but not successful:
>
> exec("c:\\windows\\system32\\cmd.exe /c $batchFileToRun");

The exec() function already calls "cmd.exe" internally, there's no need 
to call it yourself.

You've managed to omit all the relevant information:

- What $batchFileToRun is. Is it a full path? Is it in a network drive? 
Does it contain spaces?
- What the batch file does. Does it read or write files? Does it 
interact with the desktop?
- What user you are running PHP as. Is it a command line script? Does 
Apache run it as LOCAL_SYSTEM?
- What exec()'s return, output and return status are.


> Is there any option available better than exec()?

Given the question, I'd say proc_open() is "better" than exec(), but 
it's way more difficult to use. And it won't execute a script either if 
it cannot find it or does not have the appropriate permissions.


-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

[toc] | [prev] | [next] | [standalone]


#7254

FromFastian <abdulbasit.fast@gmail.com>
Date2012-10-04 22:21 -0700
Message-ID<764ff07b-1bf1-45a6-9479-85e163b5712f@googlegroups.com>
In reply to#7253
On Thursday, October 4, 2012 12:49:31 PM UTC+5, Álvaro G. Vicario wrote:
> El 04/10/2012 6:17, Fastian escribió/wrote:
> 
> > I am trying to run a batch file using exec function in PHP. The program statement executes without any error but nothing happen and batch file is not executed.
> 
> >
> 
> > The batch file is v.simple with just two commands.This batch file runs fine when I run directly from cmd.But when I use exec function from my PHP page, I am unable to run this batch file. I am not interested in the output returned by exec( ) function's argument . I am just interested in the complete execution of the batch file.
> 
> >
> 
> > I have also tried using the exec() in following way but not successful:
> 
> >
> 
> > exec("c:\\windows\\system32\\cmd.exe /c $batchFileToRun");
> 
> 
> 
> The exec() function already calls "cmd.exe" internally, there's no need 
> 
> to call it yourself.
> 
> 
> 
> You've managed to omit all the relevant information:
> 
> 
> 
> - What $batchFileToRun is. Is it a full path? Is it in a network drive? 
> 
> Does it contain spaces?
> 
> - What the batch file does. Does it read or write files? Does it 
> 
> interact with the desktop?
> 
> - What user you are running PHP as. Is it a command line script? Does 
> 
> Apache run it as LOCAL_SYSTEM?
> 
> - What exec()'s return, output and return status are.
> 
> 
> 
> 
> 
> > Is there any option available better than exec()?
> 
> 
> 
> Given the question, I'd say proc_open() is "better" than exec(), but 
> 
> it's way more difficult to use. And it won't execute a script either if 
> 
> it cannot find it or does not have the appropriate permissions.
> 
> 
> 
> 
> 
> -- 
> 
> -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
> 
> -- Mi sitio sobre programación web: http://borrame.com
> 
> -- Mi web de humor satinado: http://www.demogracia.com
> 
> --

To be precise, my batch file named show-preview.bat consist of only two commands:
latex first-program.tex
dvipng first-program.dvi

When I run show-preview.bat from cmd then they run successfully and I obtain the desired result. 
But when I use exec('show-preview.bat'); I am finding the following error in apache_error_log:
'latex' is not recognized as an internal or external command, operable program or batch file.
'dvipng' is not recognized as an internal or external command, operable program or batch file.

Whereas both of these commands are working fine from the command prompt........ what you say?

I also tried to pass the absolute path of the bat file within exec() but it also do not work. Any idea?

[toc] | [prev] | [next] | [standalone]


#7255

From"Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Date2012-10-05 09:26 +0200
Message-ID<k4m22m$j96$1@dont-email.me>
In reply to#7254
El 05/10/2012 7:21, Fastian escribió/wrote:
> To be precise, my batch file named show-preview.bat consist of only two commands:
> latex first-program.tex
> dvipng first-program.dvi
>
> When I run show-preview.bat from cmd then they run successfully and I obtain the desired result.
> But when I use exec('show-preview.bat'); I am finding the following error in apache_error_log:
> 'latex' is not recognized as an internal or external command, operable program or batch file.
> 'dvipng' is not recognized as an internal or external command, operable program or batch file.
>
> Whereas both of these commands are working fine from the command prompt........ what you say?
>
> I also tried to pass the absolute path of the bat file within exec() but it also do not work. Any idea?
>

Let's think about it. If logs complain about "latex" and "dvipng", 
doesn't that suggest that the batch file is actually being executed?


-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

[toc] | [prev] | [next] | [standalone]


#7256

FromFastian <abdulbasit.fast@gmail.com>
Date2012-10-05 00:55 -0700
Message-ID<aed5c8d3-20e1-4643-9ef8-f8b03ba98063@googlegroups.com>
In reply to#7255
On Friday, October 5, 2012 12:26:16 PM UTC+5, Álvaro G. Vicario wrote:
> El 05/10/2012 7:21, Fastian escribió/wrote:
> 
> > To be precise, my batch file named show-preview.bat consist of only two commands:
> 
> > latex first-program.tex
> 
> > dvipng first-program.dvi
> 
> >
> 
> > When I run show-preview.bat from cmd then they run successfully and I obtain the desired result.
> 
> > But when I use exec('show-preview.bat'); I am finding the following error in apache_error_log:
> 
> > 'latex' is not recognized as an internal or external command, operable program or batch file.
> 
> > 'dvipng' is not recognized as an internal or external command, operable program or batch file.
> 
> >
> 
> > Whereas both of these commands are working fine from the command prompt........ what you say?
> 
> >
> 
> > I also tried to pass the absolute path of the bat file within exec() but it also do not work. Any idea?
> 
> >
> 
> 
> 
> Let's think about it. If logs complain about "latex" and "dvipng", 
> 
> doesn't that suggest that the batch file is actually being executed?
> 
> 
> 
> 
> 
> -- 
> 
> -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
> 
> -- Mi sitio sobre programación web: http://borrame.com
> 
> -- Mi web de humor satinado: http://www.demogracia.com
> 
> --
Yes you are right! But whats the solution? 
I want to know that when the bat file is being run successfully from the command prompt then why not from Php script? On the other hand if I will write some command like  for example 'convert picture.jpg newPicture.png' in my batch file and run it from my script using exec(), it works and I get the desired result. (perhaps as 'convert' is from a Windows built-in program)
I have googled this issue and found many people discussed the same issue. People have suggested different solutions that worked for them but still I am struggling. Any good idea will highly be appreciated. Thanks!

[toc] | [prev] | [next] | [standalone]


#7259

FromShake <QUITAESTO@QUITAESTO.NOES>
Date2012-10-05 10:00 +0200
Message-ID<k4m43l$tdj$1@dont-email.me>
In reply to#7256
El 05/10/2012 9:55, Fastian escribió:
> Yes you are right! But whats the solution?
> I want to know that when the bat file is being run successfully from the command prompt then why not from Php script? On the other hand if I will write some command like  for example 'convert picture.jpg newPicture.png' in my batch file and run it from my script using exec(), it works and I get the desired result. (perhaps as 'convert' is from a Windows built-in program)
> I have googled this issue and found many people discussed the same issue. People have suggested different solutions that worked for them but still I am struggling. Any good idea will highly be appreciated. Thanks!
>

Looks like path problems.


 >>> latex first-program.tex
       1        2
 >>> dvipng first-program.dvi
       1        2


1.- Command have no absolute path.
2.- Alsto argument files have no absolute path.

Perhaps from command line you have de argument files in the directory 
where you execute the batch? PHP probably have not this path.

The error I think is clear:

'latex' is not recognized as an internal or external command, operable 
program or batch file.

If you search "not recognized as an internal or external command"  you 
will find that 'cmd' is who writes the errors. So. this text is the 
result of the php exec command.

path.... put the correct paths and everything will work.

Regards

[toc] | [prev] | [next] | [standalone]


#7260

FromFastian <abdulbasit.fast@gmail.com>
Date2012-10-05 04:24 -0700
Message-ID<7d14bacc-61dc-420b-9897-d71db48d3f61@googlegroups.com>
In reply to#7259
On Friday, October 5, 2012 1:00:53 PM UTC+5, Shake wrote:
> El 05/10/2012 9:55, Fastian escribi�:
> 
> > Yes you are right! But whats the solution?
> 
> > I want to know that when the bat file is being run successfully from the command prompt then why not from Php script? On the other hand if I will write some command like  for example 'convert picture.jpg newPicture.png' in my batch file and run it from my script using exec(), it works and I get the desired result. (perhaps as 'convert' is from a Windows built-in program)
> 
> > I have googled this issue and found many people discussed the same issue. People have suggested different solutions that worked for them but still I am struggling. Any good idea will highly be appreciated. Thanks!
> 
> >
> 
> 
> 
> Looks like path problems.
> 
> 
> 
> 
> 
>  >>> latex first-program.tex
> 
>        1        2
> 
>  >>> dvipng first-program.dvi
> 
>        1        2
> 
> 
> 
> 
> 
> 1.- Command have no absolute path.
> 
> 2.- Alsto argument files have no absolute path.
> 
> 
> 
> Perhaps from command line you have de argument files in the directory 
> 
> where you execute the batch? PHP probably have not this path.
> 
> 
> 
> The error I think is clear:
> 
> 
> 
> 'latex' is not recognized as an internal or external command, operable 
> 
> program or batch file.
> 
> 
> 
> If you search "not recognized as an internal or external command"  you 
> 
> will find that 'cmd' is who writes the errors. So. this text is the 
> 
> result of the php exec command.
> 
> 
> 
> path.... put the correct paths and everything will work.
> 
> 
> 
> Regards

You may be right that the issue is due to inappropriate paths but still I am unable to figure out the problem. As far as giving absolute paths both for command and the file; i have tested it already and it did not work. By the way, right now for the sake of simplicity my php, batch and my first-program.tex files..... all are present in the same folder on the root of www (using wamp)

On google the error, I found the following link which suggest setting up of PATH if you are unable to run the latex command from cmd:
http://educ.jmu.edu/~taalmala/245_2006post/miktex/miktex_setup.html

[toc] | [prev] | [next] | [standalone]


#7257

FromTim Streater <timstreater@greenbee.net>
Date2012-10-05 08:56 +0100
Message-ID<timstreater-66EBE3.08561105102012@news.individual.net>
In reply to#7254
In article <764ff07b-1bf1-45a6-9479-85e163b5712f@googlegroups.com>,
 Fastian <abdulbasit.fast@gmail.com> wrote:

> To be precise, my batch file named show-preview.bat consist of only two 
> commands:
> latex first-program.tex
> dvipng first-program.dvi
> 
> When I run show-preview.bat from cmd then they run successfully and I obtain 
> the desired result. 
> But when I use exec('show-preview.bat'); I am finding the following error in 
> apache_error_log:
> 'latex' is not recognized as an internal or external command, operable 
> program or batch file.
> 'dvipng' is not recognized as an internal or external command, operable 
> program or batch file.
> 
> Whereas both of these commands are working fine from the command 
> prompt........ what you say?
> 
> I also tried to pass the absolute path of the bat file within exec() but it 
> also do not work. Any idea?

Don't you need the absolute paths of latex etc within the batch file?

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#7258

FromFastian <abdulbasit.fast@gmail.com>
Date2012-10-05 01:00 -0700
Message-ID<f8e25ffc-9e5e-4e8a-a8eb-74bab60f3554@googlegroups.com>
In reply to#7257
On Friday, October 5, 2012 12:56:13 PM UTC+5, Tim Streater wrote:
> In article <764ff07b-1bf1-45a6-9479-85e163b5712f@googlegroups.com>,
> 
>  Fastian <abdulbasit.fast@gmail.com> wrote:
> 
> 
> 
> > To be precise, my batch file named show-preview.bat consist of only two 
> 
> > commands:
> 
> > latex first-program.tex
> 
> > dvipng first-program.dvi
> 
> > 
> 
> > When I run show-preview.bat from cmd then they run successfully and I obtain 
> 
> > the desired result. 
> 
> > But when I use exec('show-preview.bat'); I am finding the following error in 
> 
> > apache_error_log:
> 
> > 'latex' is not recognized as an internal or external command, operable 
> 
> > program or batch file.
> 
> > 'dvipng' is not recognized as an internal or external command, operable 
> 
> > program or batch file.
> 
> > 
> 
> > Whereas both of these commands are working fine from the command 
> 
> > prompt........ what you say?
> 
> > 
> 
> > I also tried to pass the absolute path of the bat file within exec() but it 
> 
> > also do not work. Any idea?
> 
> 
> 
> Don't you need the absolute paths of latex etc within the batch file?
> 
> 
> 
> -- 
> 
> Tim
> 
> 
> 
> "That excessive bail ought not to be required, nor excessive fines imposed,
> 
> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689


I have also tried with the absolute path of the latex but no success.

[toc] | [prev] | [next] | [standalone]


#7261

Frombill <william@TechServSys.com>
Date2012-10-05 07:35 -0400
Message-ID<k4mgmf$vdu$1@speranza.aioe.org>
In reply to#7258
On 10/5/2012 4:00 AM, Fastian wrote:
> On Friday, October 5, 2012 12:56:13 PM UTC+5, Tim Streater wrote:
>> In article <764ff07b-1bf1-45a6-9479-85e163b5712f@googlegroups.com>,
>>
>>   Fastian <abdulbasit.fast@gmail.com> wrote:
>>
>>
>>
>>> To be precise, my batch file named show-preview.bat consist of only two
>>
>>> commands:
>>
>>> latex first-program.tex
>>
>>> dvipng first-program.dvi
>>
>>>
>>
>>> When I run show-preview.bat from cmd then they run successfully and I obtain
>>
>>> the desired result.
>>
>>> But when I use exec('show-preview.bat'); I am finding the following error in
>>
>>> apache_error_log:
>>
>>> 'latex' is not recognized as an internal or external command, operable
>>
>>> program or batch file.
>>
>>> 'dvipng' is not recognized as an internal or external command, operable
>>
>>> program or batch file.
>>
>>>
>>
>>> Whereas both of these commands are working fine from the command
>>
>>> prompt........ what you say?
>>
>>>
>>
>>> I also tried to pass the absolute path of the bat file within exec() but it
>>
>>> also do not work. Any idea?
>>
>>
>>
>> Don't you need the absolute paths of latex etc within the batch file?
>>
>>
>>
>> --
>>
>> Tim
>>
>>
>>
>> "That excessive bail ought not to be required, nor excessive fines imposed,
>>
>> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689
>
>
> I have also tried with the absolute path of the latex but no success.
>
as others have said, this looks like a path problem.
Apache runs with a different path than the windows command line.

Try rewriting the commands in the batch file with complete paths 
and then execute it from windows command line and then from Apache.
Then if it doesn't work copy and paste it here (not retyping it).

BTW, to quote the revered Jerry, "this is not a PHP question."

bill

[toc] | [prev] | [next] | [standalone]


#7268

FromFastian <abdulbasit.fast@gmail.com>
Date2012-10-07 21:33 -0700
Message-ID<0e7d688a-57d2-4caf-b8a0-48ecabfe8c48@googlegroups.com>
In reply to#7261
On Friday, October 5, 2012 4:35:48 PM UTC+5, bill wrote:
> On 10/5/2012 4:00 AM, Fastian wrote:
> 
> > On Friday, October 5, 2012 12:56:13 PM UTC+5, Tim Streater wrote:
> 
> >> In article <764ff07b-1bf1-45a6-9479-85e163b5712f@googlegroups.com>,
> 
> >>
> 
> >>  
> 
> >>
> 
> >>
> 
> >>
> 
> >>> To be precise, my batch file named show-preview.bat consist of only two
> 
> >>
> 
> >>> commands:
> 
> >>
> 
> >>> latex first-program.tex
> 
> >>
> 
> >>> dvipng first-program.dvi
> 
> >>
> 
> >>>
> 
> >>
> 
> >>> When I run show-preview.bat from cmd then they run successfully and I obtain
> 
> >>
> 
> >>> the desired result.
> 
> >>
> 
> >>> But when I use exec('show-preview.bat'); I am finding the following error in
> 
> >>
> 
> >>> apache_error_log:
> 
> >>
> 
> >>> 'latex' is not recognized as an internal or external command, operable
> 
> >>
> 
> >>> program or batch file.
> 
> >>
> 
> >>> 'dvipng' is not recognized as an internal or external command, operable
> 
> >>
> 
> >>> program or batch file.
> 
> >>
> 
> >>>
> 
> >>
> 
> >>> Whereas both of these commands are working fine from the command
> 
> >>
> 
> >>> prompt........ what you say?
> 
> >>
> 
> >>>
> 
> >>
> 
> >>> I also tried to pass the absolute path of the bat file within exec() but it
> 
> >>
> 
> >>> also do not work. Any idea?
> 
> >>
> 
> >>
> 
> >>
> 
> >> Don't you need the absolute paths of latex etc within the batch file?
> 
> >>
> 
> >>
> 
> >>
> 
> >> --
> 
> >>
> 
> >> Tim
> 
> >>
> 
> >>
> 
> >>
> 
> >> "That excessive bail ought not to be required, nor excessive fines imposed,
> 
> >>
> 
> >> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689
> 
> >
> 
> >
> 
> > I have also tried with the absolute path of the latex but no success.
> 
> >
> 
> as others have said, this looks like a path problem.
> 
> Apache runs with a different path than the windows command line.
> 
> 
> 
> Try rewriting the commands in the batch file with complete paths 
> 
> and then execute it from windows command line and then from Apache.
> 
> Then if it doesn't work copy and paste it here (not retyping it).
> 
> 
> 
> BTW, to quote the revered Jerry, "this is not a PHP question."
> 
> 
> 
> bill

My batch file:
C:\TeX\miktex\bin\latex.exe "E:\wamp\wamp\www\first-program.tex"
C:\TeX\miktex\bin\dvipng.exe "E:\wamp\wamp\www\first-program.dvi"

(BTW I have tried with double back slash as well as with forward slash in the path)

Runs perfectly fine when i just run the batch file from the command line.

But when I try to run the same batch file using the following php line of code:
 exec('showpreview.bat');
the apache error log reports
latex.exe: The memory dump file could not be found.
latex.exe: Data: latex.fmt

Now what you say? Where I am wrong?

[toc] | [prev] | [next] | [standalone]


#7270

FromFastian <abdulbasit.fast@gmail.com>
Date2012-10-08 03:19 -0700
Message-ID<7f6a560e-5070-49bf-b533-b6e1e1bb92ea@googlegroups.com>
In reply to#7268
On Monday, October 8, 2012 9:33:31 AM UTC+5, Fastian wrote:
> On Friday, October 5, 2012 4:35:48 PM UTC+5, bill wrote:
> 
> > On 10/5/2012 4:00 AM, Fastian wrote:
> 
> > 
> 
> > > On Friday, October 5, 2012 12:56:13 PM UTC+5, Tim Streater wrote:
> 
> > 
> 
> > >> In article <764ff07b-1bf1-45a6-9479-85e163b5712f@googlegroups.com>,
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>  
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> To be precise, my batch file named show-preview.bat consist of only two
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> commands:
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> latex first-program.tex
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> dvipng first-program.dvi
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> When I run show-preview.bat from cmd then they run successfully and I obtain
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> the desired result.
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> But when I use exec('show-preview.bat'); I am finding the following error in
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> apache_error_log:
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> 'latex' is not recognized as an internal or external command, operable
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> program or batch file.
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> 'dvipng' is not recognized as an internal or external command, operable
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> program or batch file.
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> Whereas both of these commands are working fine from the command
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> prompt........ what you say?
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> I also tried to pass the absolute path of the bat file within exec() but it
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>> also do not work. Any idea?
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> Don't you need the absolute paths of latex etc within the batch file?
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> --
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> Tim
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> "That excessive bail ought not to be required, nor excessive fines imposed,
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689
> 
> > 
> 
> > >
> 
> > 
> 
> > >
> 
> > 
> 
> > > I have also tried with the absolute path of the latex but no success.
> 
> > 
> 
> > >
> 
> > 
> 
> > as others have said, this looks like a path problem.
> 
> > 
> 
> > Apache runs with a different path than the windows command line.
> 
> > 
> 
> > 
> 
> > 
> 
> > Try rewriting the commands in the batch file with complete paths 
> 
> > 
> 
> > and then execute it from windows command line and then from Apache.
> 
> > 
> 
> > Then if it doesn't work copy and paste it here (not retyping it).
> 
> > 
> 
> > 
> 
> > 
> 
> > BTW, to quote the revered Jerry, "this is not a PHP question."
> 
> > 
> 
> > 
> 
> > 
> 
> > bill
> 
> 
> 
> My batch file:
> 
> C:\TeX\miktex\bin\latex.exe "E:\wamp\wamp\www\first-program.tex"
> 
> C:\TeX\miktex\bin\dvipng.exe "E:\wamp\wamp\www\first-program.dvi"
> 
> 
> 
> (BTW I have tried with double back slash as well as with forward slash in the path)
> 
> 
> 
> Runs perfectly fine when i just run the batch file from the command line.
> 
> 
> 
> But when I try to run the same batch file using the following php line of code:
> 
>  exec('showpreview.bat');
> 
> the apache error log reports
> 
> latex.exe: The memory dump file could not be found.
> 
> latex.exe: Data: latex.fmt
> 
> 
> 
> Now what you say? Where I am wrong?

A strange finding:
Today I found someone with a similar issue on the following link:
http://board.phpbuilder.com/showthread.php?10366149-RESOLVED-Executing-an-application-from-PHP

It suggested to use EasyPhp. I tried with it and everything started working as desired. Thanks to Allah(subhanahu watala).

It is working whether you specify the absolute path or relative path. so doesn't seems to be a 'path' related issue.

After reading the thread mentioned above if some one can identify the real issue then it will be really worthy.  

[toc] | [prev] | [next] | [standalone]


#7273

FromErwin Moller <erwinmollerusenet@xs4all.nl>
Date2012-10-08 15:16 +0200
Message-ID<5072d223$0$6867$e4fe514c@news2.news.xs4all.nl>
In reply to#7270
On 10/8/2012 12:19 PM, Fastian wrote:

<snip>

>
> A strange finding:
> Today I found someone with a similar issue on the following link:
> http://board.phpbuilder.com/showthread.php?10366149-RESOLVED-Executing-an-application-from-PHP
>
> It suggested to use EasyPhp. I tried with it and everything started working as desired. Thanks to Allah(subhanahu watala).
>
> It is working whether you specify the absolute path or relative path. so doesn't seems to be a 'path' related issue.
>
> After reading the thread mentioned above if some one can identify the real issue then it will be really worthy.
>

In my opinion this nicely demonstrates (again) why everybody should 
install PHP by hand instead of using an "easy" prepackaged 
all-in-one-plus-more solution, unless you fully understand it.
It actually costs time in the long run to use "easy" solutions.

Installing PHP by hand isn't that hard, and you learn a lot about the 
set-up.

What did you learn now?
Old setup isn't "working", new one with EasyPHP is.
So what? What does that mean?
Why did the old setup not interpret/find your path the way you intended?

I dislike such "solutions" (but I am glad for you it works now).
You should wonder: What you will do when another piece of code doesn't 
work as intended?
Will you switch to yet another "easy php install"?

Regards,
Erwin Moller

PS: I have no experience with EasyPHP at all, so maybe it is great.

-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

[toc] | [prev] | [next] | [standalone]


#7278

From"Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Date2012-10-09 12:18 +0200
Message-ID<k50tm9$s04$1@dont-email.me>
In reply to#7270
El 08/10/2012 12:19, Fastian escribió/wrote:
>> My batch file:
>>
>> C:\TeX\miktex\bin\latex.exe "E:\wamp\wamp\www\first-program.tex"
>>
>> C:\TeX\miktex\bin\dvipng.exe "E:\wamp\wamp\www\first-program.dvi"
>>
>>
>>
>> (BTW I have tried with double back slash as well as with forward slash in the path)

Backslash is not a escape character in Windows batch.

>> But when I try to run the same batch file using the following php line of code:
>>
>>   exec('showpreview.bat');
>>
>> the apache error log reports
>>
>> latex.exe: The memory dump file could not be found.

Your error messages seem to be changing along time... This one suggests 
that latex just crashed :-?

> Today I found someone with a similar issue on the following link:
> http://board.phpbuilder.com/showthread.php?10366149-RESOLVED-Executing-an-application-from-PHP
>
> It suggested to use EasyPhp. I tried with it and everything started working as desired. Thanks to Allah(subhanahu watala).
>
> It is working whether you specify the absolute path or relative path. so doesn't seems to be a 'path' related issue.
>
> After reading the thread mentioned above if some one can identify the real issue then it will be really worthy.

If you get a PHP crash then you've hit a bug. And you upgrade/downgrade 
to a PHP version after/before the bug was fixed/introduced it's not 
surprising that the bug is gone. Who compiled that PHP version does not 
look particularly relevant.


-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web