好吧,我知道我在这里做一些奇怪的事情,但我必须这样做。
所以我的elixir程序需要运行一个PHP脚本并从脚本中获取信息,但它永远不会进入。我可以手动运行php脚本,并且它工作正常。 在脚本的底部它说:
echo $avar->getPUId();所以它打印出来回应我的猜测。 从命令行运行它时,我得到需要的数据:
C:\PHP>php.exe "-f" "C:\pap.php" "613b8859" 37a69912但是,当我从iex运行它时,我什么也得不到:
iex(1)> System.cmd("C:\\PHP\\php.exe", ["-f", "C:\\pap.php", "613b8859"]) Terminate batch job (Y/N)? y现在,如果我搞砸了文件名或PHP会给我一个错误的回应说:
iex(1)> System.cmd("C:\\PHP\\php.exe", ["-f", "C:\\pap321.php", "613b8859"]) {"Could not open input file: c:/pap123.php\n", 1} ...所以我知道我可以与PHP交谈,并且可以通过错误回复给我,但回显并没有被我的elixir应用程序所捕获,而这个应用程序显然会调用它。 有没有其他方法可以抓取数据,因为它是从PHP脚本中提取出来的?
ok, I know I'm doing something weird here but I gotta do it.
So my elixir program needs to run one PHP script and take the information from that script, but it never comes in. I can manually run the php script and it works fine. At the bottom of the script it says:
echo $avar->getPUId();So it's printing it out to echo I guess. I get the data I need when I run it from a command line:
C:\PHP>php.exe "-f" "C:\pap.php" "613b8859" 37a69912But when I run it from iex I get nothing:
iex(1)> System.cmd("C:\\PHP\\php.exe", ["-f", "C:\\pap.php", "613b8859"]) Terminate batch job (Y/N)? yNow, if I mess up on the filename or something php will give me an error in response saying like:
iex(1)> System.cmd("C:\\PHP\\php.exe", ["-f", "C:\\pap321.php", "613b8859"]) {"Could not open input file: c:/pap123.php\n", 1} ...so I know I can talk to PHP, and it can talk back to me with errors, but echo isn't caught by my elixir application that calls it apparently. Is there any other way I can grab the data as it comes out of the PHP script?
最满意答案
我用了
https://github.com/alco/porcelain
result = Porcelain.shell("C:\\PHP\\php.exe -f C:\\pap.php 613b8859") IO.inspect result.out它效果很好。
I used
https://github.com/alco/porcelain
result = Porcelain.shell("C:\\PHP\\php.exe -f C:\\pap.php 613b8859") IO.inspect result.outit worked great.
更多推荐
发布评论