0

I am using Boris—"A tiny little, but robust REPL for PHP". To be more specific, I am using WP-CLI's implementation of Boris (wp shell—it replaces the $boris command prompt with wp>).

I was wondering if it was possible to pipe the command line output to say, a text file. For example, I want to capture my PHP info to a text file. Here is what happens when I execute phpinfo();

wp> phpinfo();

    phpinfo()
    PHP Version => 5.3.14

    System => Darwin Macintosh-HD.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
    Build Date => Jul  4 2012 17:23:04
    Configure Command =>  './configure'  '--with-mysql=/...

    //phpinfo() output continues here

I want to redirect this output from the standard display to a text file. I know this is bash syntax, but this is what I want to achieve in theory :

wp> phpinfo(); > phpinfo.txt

    // phpinfo.txt now contains phpinfo() output

Is there any way to make this work?

JP Lew
  • 4,121
  • 2
  • 32
  • 45
  • Never used this shell, but can you pass commands to it from terminal when you open it? You should be able to `>` the output at that stage. – John V. Sep 15 '13 at 07:10
  • it worked! Thanks @JohnV. Here is what I did: `wp shell > phpinfo.txt`. Then I ran my commands, exited the shell, and voila, the text file was there. Please add your suggestion as an answer so I can upvote. – JP Lew Sep 15 '13 at 07:13

1 Answers1

1

You should be able to use the bash syntax on the command that opens the shell, try it there.

EX:

wp_shell > output.txt

Where "wp_shell" is the command that opens your prompt. You might be able to pass phpinfo directly to the prompt as well if you want to not have to open it, if there is a way to pass direct script to it as with the default php CLI.

John V.
  • 4,652
  • 4
  • 26
  • 26