views:

159

answers:

2

I have a PHP script that executes a .bat file using

system("cmd /c C:\dir\file.bat");

This launches an AWS server and returns info such as the id of the server started. I need to use this id in the script later on. How can I return the results from the .bat file to PHP and then how can I extract the id from the rest of the results. Is the returned data simply a string that i need to slice to get the bit i need?

I will then run a .bat file that executes the following -

ec2-associate-address -i i-######id  ip.###.###.###

Thanks all

+1  A: 

You can capture the output of a system command by using the exec() function or passthru() function.

Matt
A: 

Instead of system() you can use proc_open(). That way you can read the output of your .bat file by reading the stdout pipe. You then get your simple string that you can slice 'n dice to get your process ID.

Sander Marechal