Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="https://stackoverflow.com/questions/4399617/python-os-getlogin-problem">This previous answer about Errno 22 when using <code>os.getlogin</code></a> should be enlightening:</p> <blockquote> <p>From the <code>os.getlogin()</code> <a href="http://docs.python.org/library/os.html#os.getlogin" rel="nofollow noreferrer">docs</a>: "Returns the user logged in to the controlling terminal of the process." Your script does not have a controlling terminal when run from cron. The docs go on to suggest: "For most purposes, it is more useful to use the environment variable <code>LOGNAME</code> to find out who the user is, or <code>pwd.getpwuid(os.getuid())[0]</code> to get the login name of the currently effective user id."</p> </blockquote> <p>You're calling the script via <code>passthru()</code> in PHP. PHP will be running as the web server user -- frequently <code>nobody</code> or <code>apache</code> -- and like cron, that user will also not be control a terminal.</p> <p>While you might be able to patch the code, you will probably be better served by filing a bug with the python-lastfm project with what you've uncovered. Unfortunately I don't know enough Python to help with that task, and also don't know enough about why the python-lastfm application wants to get the current user. It <em>looks</em> like it's just looking for a temporary file path and is trying to be clever about it.</p> <p>An alternative to patching might be setting environment variables for the script, but there isn't an apparent way to do this for <code>passthru</code>. Perhaps you can try using <a href="http://us2.php.net/manual/en/function.putenv.php" rel="nofollow noreferrer"><code>putenv('USER=myname')</code></a> before calling <code>passthru</code>, where 'myname' is your shell login name.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload