Link to home
Create AccountLog in
Avatar of gesmuk
gesmuk

asked on

PHP & Powershell

Hi guys,

I'm using PHP to run a Powershell script in an external file. The script runs, pulls some information from a database, and then writes the info to a txt file. This is working fine.

Now instead of writing the info into a text file, I want to pass it back the PHP page as an array,

Any suggestions of how I can do this?

Cheers,
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

Hmm not sure if you can do that exactly but you could let the script finish executing then open the log file with php and read it into an array. Depends on how you are calling the external script. If you are opening a powershell and typing php filename.php then you can edit that file and have it create the array and output it to the screen or var_dump($array); and you would see what is in the array that way.

Other than that you would need to have another php script which calls the first script and when it is finished, open the log file and read the data.
ASKER CERTIFIED SOLUTION
Avatar of Robert Saylor
Robert Saylor
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of gesmuk
gesmuk

ASKER

Thanks guys, went for the method of writing the result to a text file and reading it back in. A little dirty, but get's the result!

Cheers,