php回应elixir iex stdin(php echo to elixir iex stdin)

编程入门 行业动态 更新时间:2024-10-11 03:15:22
php回应elixir iex stdin(php echo to elixir iex stdin)

好吧,我知道我在这里做一些奇怪的事情,但我必须这样做。

所以我的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" 37a69912

But 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)? y

Now, 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.out

it worked great.

更多推荐

本文发布于:2023-08-07 23:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466682.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:elixir   php   iex   echo   stdin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!