FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to run a batch file using PHP?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How to run a batch file using PHP? [message #179338 is a reply to message #179336] Mon, 08 October 2012 10:19 Go to previous messageGo to previous message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma:
Junior Member
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(at)googlegroups(dot)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-a pplication-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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: JOB - Sr. PHP Developer - Fort Lauderdale, FL - Relo/Sponsor OK
Next Topic: Regular Expression Help
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 04:06:18 GMT 2024

Total time taken to generate the page: 0.04507 seconds