Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7253
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: How to run a batch file using PHP? |
| Date | 2012-10-04 09:49 +0200 |
| Organization | http://alvaro.es/ |
| Message-ID | <k4jf2b$57o$1@dont-email.me> (permalink) |
| References | <6a8001c9-b576-4b49-bbef-cef6de443c0f@googlegroups.com> |
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
--
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web