return value from php to batch file -


i have batch file calls php script. php script returns value want use in batch script. php script echoes correct return value have not been able find way capture value use in batch file.

i have tried number of variations on loops without success. batch script follows:

@echo off setlocal  "c:\program files (x86)\php\v5.3\php.exe" -f c:\inetpub\wwwroot\hello.php  endlocal 

this of course returns "hello." how can set variable in batch file (a variable named retvar example) contain returned php call?

thank you, shimon

@echo off     setlocal enableextensions     /f "delims=" %%a in (        '"c:\program files (x86)\php\v5.3\php.exe" -f c:\inetpub\wwwroot\hello.php'     ) set "retvar=%%a"      echo %retvar% 

use for /f execute command (in in clause) , each line in command output, execute block of code (in do clase). each line, variable/replaceable parameter (%%a in sample code) hold line. in case, output of php command 1 line, executed 1 time, storing php output line retvar variable.

for /f will, default, try tokenize lines reads, splitting in fields using spaces delimiters. avoid behaviour, empty list of delimiters used, line contents stored in %%a


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -