Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在.php文件中使用HD-WALLET-DERIVE?_Php_Ubuntu - Fatal编程技术网

如何在.php文件中使用HD-WALLET-DERIVE?

如何在.php文件中使用HD-WALLET-DERIVE?,php,ubuntu,Php,Ubuntu,我想在我的网站中使用来自的命令 例如,我在Ubuntu终端上运行了这个程序,效果很好: $ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --path=m/1 --cols=all --includeroot --numderive=3 但是如何在PHP文

我想在我的网站中使用来自的命令

例如,我在Ubuntu终端上运行了这个程序,效果很好:

$ ./hd-wallet-derive.php -g --key=xprv9tyUQV64JT5qs3RSTJkXCWKMyUgoQp7F3hA1xzG6ZGu6u6Q9VMNjGr67Lctvy5P8oyaYAL9CAWrUE9i6GoNMKUga5biW6Hx4tws2six3b9c --path=m/1 --cols=all --includeroot --numderive=3
但是如何在PHP文件中使用这些代码并获得输出呢


例如,如果我单击PHP页面中的一个按钮,下面的命令run?

hd-wallet-derive将使用信息发送到stderr,而不是stdout。要捕获它,您可以运行命令,例如:./hd-g 2>&1

不过,对于您的问题,还有一个选项-outfile=将报告输出写入给定文件。在web应用程序中,应为用户指定唯一的文件名。此外,还可以使用-format标志指定所需的报告输出类型

使用信息如下:

您搜索的代码-format=jsonpretty和-outfile=logs/shell_result.txt

    $cmd = 'php hd2/hd-wallet-derive.php --mnemonic="edge defense waste choose enrich upon flee junk siren film clown finish luggage leader kid quick brick print evidence swap drill paddle truly occur" ';
    $cmd.= '-g --path=m/44/60/0 --cols=all --includeroot --numderive=3 ';
    $cmd.= '--format=jsonpretty ';
    $cmd.= '--outfile="logs/shell_result.txt"';

    shell_exec($cmd);
    print_r(json_decode(file_get_contents('logs/shell_result.txt'), true));

请详细说明works fine的含义。这是否包括提供一些输出,或者您只需要运行这些命令?当我使用我在ubuntu终端上编写的命令时,它会给我输出。那么如何在.php文件中接收相同的输出呢?如何在.php文件中使用-g并获得输出?您可以使用exec函数从php代码中运行terminal命令。评论中的链接可能会有所帮助。简短的答案似乎是——不可能通过include。您链接的脚本使用getopt,因此一个问题本质上是–如何将选项传递给使用getopt的脚本。也许Valerian建议的方法是Tank u guys唯一的选择,当我创建一个.php文件并复制其中的代码时,“我如何使用这个库获得像数组一样的php响应?”。我想将其用作标准PHP库。你能指导我们如何做到这一点吗?