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 #179323 is a reply to message #179322] Thu, 04 October 2012 07:49 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
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
--
[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:00:55 GMT 2024

Total time taken to generate the page: 0.04358 seconds