Minifrij
Minifrij

Reputation: 31

PHP exec() and shell_exec() not outputting everything

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.

Upvotes: 0

Views: 156

Answers (1)

Minifrij
Minifrij

Reputation: 31

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');

Upvotes: 1

Related Questions