Bitcoin Forum

Bitcoin => Electrum => Topic started by: TimeIsBitcoin on September 11, 2013, 06:46:53 PM



Title: Error trying to run electrum through PHP's shell_exec()
Post by: TimeIsBitcoin on September 11, 2013, 06:46:53 PM
I'm trying to use Electrum from the command line for a little project of mine using PHP. Running commands from the terminal (in Ubuntu) works just fine. But when I try running them through PHP using something like $output = `/usr/local/bin/electrum listaddresses 2>&1`;, I get the following error:

Code:
Traceback (most recent call last):
  File "/usr/local/bin/electrum", line 108, in
    config = SimpleConfig(config_options)
  File "/usr/local/lib/python2.7/dist-packages/electrum/simple_config.py", line 34, in __init__
    self.init_path(self.options_config.get('wallet_path'))
  File "/usr/local/lib/python2.7/dist-packages/electrum/simple_config.py", line 166, in init_path
    if not os.path.exists(self.user_dir):
  File "/usr/lib/python2.7/genericpath.py", line 18, in exists
    os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found

Do you have any idea why that would be? It's running php on the same machine, with the same owner as I ran in the terminal, so I can't imagine it being a permissions issue.

Thanks a bunch.


Title: Re: Error trying to run electrum through PHP's shell_exec()
Post by: TimeIsBitcoin on September 12, 2013, 02:02:46 AM
I've found the problem, though I don't know the proper solution, since I'm not too familiar with python. Apparently "os.environ" isn't giving me the complete info in util.py when the program is executed using PHP's shell_exec(). "HOME" is missing, for some reason (as well as other things), so it returns nothing, causing this error. I just hard coded my directory path in for now until I find a fix.