Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/07/2008, 18:26
tld32
 
Fecha de Ingreso: julio-2008
Mensajes: 201
Antigüedad: 15 años, 9 meses
Puntos: 11
Respuesta: Ejecutar .BAT en PHP

Muchas gracias pato12 y eddwinpaz.

He encontrado uno : http://ve.php.net/manual/en/function.exec.php#81543 pero no se realmente que es a lo que se refiere, si alguien me puede ayudar se lo agracedería.

Cita:
You can embed php into a batch file so that it is essentially "double-click" to run. This might be useful for script that does search and replace in numerous files or other tedious task that are too complex for batch files but don't warrant greater attention. Its really quite simple I'm sure someone has thought of it before. You can add whatever batch code you want after :START just make sure you exit before you get to */ so Windows doesn't fuss. @php %0 basically is saying "Open this file with php and run its php code". Obviously its really only a useful trick on Windows, I only really use it for update scripts on our company's servers. I suppose you could also just set Windows to open php files with php.exe but that seems like a rather stupid thing to do as you would most often want to edit php files, not run them directly. @pause is optional of course, but you may want to look at what php outputted to the command line before it exits.

example.bat:

@GOTO START
<?php

...php code...

/*
:START
...batch code...
@php %0
@pause
@exit
*/
?>
Un saludo y gracias