1

I'm basically making a webpage that can play spotify music on my computer using a Mac spotify api. You access it by typing spotify <command> on command line, and I got it to work perfectly in my PHP script using the exec() command, and this was working for a week or so.

Today, after a computer reboot, it isn't working. I've tried everything. When I execute the php script via command line, it works perfectly, but when I access the same exact file via the web, it doesn't work.

The odd thing is: when I try to get the output, it outputs exactly as if it was working (example: spotify play doesn't play music but it gives the correct output of Playing music, etc). I read on another StackOverflow that if you add 2>&1 to the end of the command, it gives the full output -- and this is where I found what is wrong. It gives the error 30:95: execution error: An error of type -10810 has occurred. (-10810). I have no idea what this is and Googling it yields no helpful results.

Any ideas? Thanks.

Jamsheed Mistri
  • 419
  • 1
  • 4
  • 19
  • `-10810` appears to be an unknown error (http://www.thexlab.com/faqs/error-10810.html). However, I am guessing that your terminal execution environment that is accessible to through the web application is not the same as the one in your default Terminal window. It might be operated by a different user with different privileges, and it may have some other environment variables. Try comparing the exposed environment variables, and try running $(whoami) from using `exec`. – arik Dec 30 '16 at 07:35
  • Alright, so I tried to execute the command as myself since `echo exec("whoami")` gave `daemon`, meaning I can't execute commands as my user from php (which is odd since it was working before) - anyway I tried to add the user `_www` to the sudoers file and then start the commands with `sudo -u ` so it would execute as myself. I'm getting this back: `sudo: no tty present and no askpass program specified`... hmm any help? – Jamsheed Mistri Dec 30 '16 at 08:35
  • There is a Stackoverflow post for this: https://stackoverflow.com/questions/21659637/how-to-fix-sudo-no-tty-present-and-no-askpass-program-specified-error. However, you should only use this workaround temporarily, and figure out a way of getting it to work without sudo before exposing it online, as it would pose a serious security risk to your machine. – arik Dec 30 '16 at 08:38
  • Yeah, that's where I got my answer from. Here's the line I put in the sudoers file: `_www ALL=(ALL) NOPASSWD: ALL`. Should work, right? It doesn't :( – Jamsheed Mistri Dec 30 '16 at 23:14

0 Answers0