Answer the question
In order to leave comments, you need to log in
Exception from PowerShell to PHP
Good afternoon,
Tell me how to intercept an exception in PHP from PowerShell:
c:\rest>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File C:\rest\Scripts\check-deploy.ps1
требуется имя хоста
At C:\rest\Scripts\check-deploy.ps1:3 char:24
+ $hostName = $(throw <<<< "требуется имя хоста"),
+ CategoryInfo : OperationStopped: (требуется имя хоста:String) [
], RuntimeException
+ FullyQualifiedErrorId : требуется имя хоста
Answer the question
In order to leave comments, you need to log in
I run from PHP with system('%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File C:\rest\Scripts\check-deploy.ps1') command (tried both exec and shell_exec), but powershell -script just stays hanging in the processes, and because of this, the php script waits and dies by timeout.
so far the problem was solved by forking through exec("psexec check-deploy-runner.bat". microtime()). (psexec creates a correct fork that detaches from the Php script.
In the bat file I have: "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File C:\rest\Scripts\check-deploy.ps1 > %1.log" (%1 is the first parameter that is passed to the bat script and which creates a log file)
Then I parse the log file to find the answer.
The solution is very hacky, but this is the only thing I could run.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question