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
Switch to threaded view of this topic Create a new topic Submit Reply
How to run a batch file using PHP? [message #179322] Thu, 04 October 2012 04:17 Go to next message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma: 0
Junior Member
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?
Re: How to run a batch file using PHP? [message #179323 is a reply to message #179322] Thu, 04 October 2012 07:49 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
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
--
Re: How to run a batch file using PHP? [message #179324 is a reply to message #179323] Fri, 05 October 2012 05:21 Go to previous messageGo to next message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma: 0
Junior Member
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?
Re: How to run a batch file using PHP? [message #179325 is a reply to message #179324] Fri, 05 October 2012 07:26 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
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
--
Re: How to run a batch file using PHP? [message #179326 is a reply to message #179325] Fri, 05 October 2012 07:55 Go to previous messageGo to next message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma: 0
Junior Member
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!
Re: How to run a batch file using PHP? [message #179327 is a reply to message #179324] Fri, 05 October 2012 07:56 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <764ff07b-1bf1-45a6-9479-85e163b5712f(at)googlegroups(dot)com>,
Fastian <abdulbasit(dot)fast(at)gmail(dot)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
Re: How to run a batch file using PHP? [message #179328 is a reply to message #179327] Fri, 05 October 2012 08:00 Go to previous messageGo to next message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma: 0
Junior Member
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>,
>
> Fastian <abdulbasit(dot)fast(at)gmail(dot)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.
Re: How to run a batch file using PHP? [message #179329 is a reply to message #179326] Fri, 05 October 2012 08:00 Go to previous messageGo to next message
Shake is currently offline  Shake
Messages: 40
Registered: May 2012
Karma: 0
Member
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
Re: How to run a batch file using PHP? [message #179330 is a reply to message #179329] Fri, 05 October 2012 11:24 Go to previous messageGo to next message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma: 0
Junior Member
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
Re: How to run a batch file using PHP? [message #179331 is a reply to message #179328] Fri, 05 October 2012 11:35 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
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>,
>>
>> Fastian <abdulbasit(dot)fast(at)gmail(dot)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
Re: How to run a batch file using PHP? [message #179336 is a reply to message #179331] Mon, 08 October 2012 04:33 Go to previous messageGo to next message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma: 0
Junior Member
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?
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 next message
Fastian is currently offline  Fastian
Messages: 20
Registered: June 2012
Karma: 0
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.
Re: How to run a batch file using PHP? [message #179341 is a reply to message #179338] Mon, 08 October 2012 13:16 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
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-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.
>

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
Re: How to run a batch file using PHP? [message #179346 is a reply to message #179338] Tue, 09 October 2012 10:18 Go to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
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-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.

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
--
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Sat Nov 23 11:44:45 GMT 2024

Total time taken to generate the page: 0.03107 seconds