0

I am trying to get a certain detail from an external program using shell_exec() in PHP. Here is what I am querying:

$output = shell_exec('vanitygen.exe 1z');

When doing this in the command prompt on windows it returns this information:

Difficulty: 1353
Pattern: 1z
Address: address
Privkey: private_key

However, when running the same command using PHP shell_exec (and exec) only this is returned:

Pattern: 1z
Address: address
Privkey: private_key

Is there any way to have PHP give all information, including the 'Difficulty: 1353' line?
Thanks.

2
  • 2
    I'll bet that the missing output is in STDERR. Commented Feb 11, 2017 at 2:11
  • You were right. Commented Feb 11, 2017 at 2:15

1 Answer 1

1

Turns out that the information that I wanted was stored in STDERR.
To get this information, you simply have to append this to the end of the exec query:

2>&1

In this case, this turns the query from:

$output = shell_exec('vanitygen.exe 1z');

to

$output = shell_exec('vanitygen.exe 1z 2>&1');

Sign up to request clarification or add additional context in comments.

1 Comment

Though it's likely overkill, you can also use proc_open() which allows you to manage all I/O streams for the process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.