Update from older Piwik

When I do I get Piwik update always the following error message:


There is an error. Please report the message (Piwik 2.4.0) and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning: shell_exec(): Unable to execute 'whoami' in x:\Folder\statistic\data\core\Filechecks.php on line 232

Backtrace -->

#0 Piwik\Error::errorHandler(...) called at [:]
#1 shell_exec(...) called at [x:\Folder\statistic\data\core\Filechecks.php:232]
#2 Piwik\Filechecks::getUser(...) called at [x:\Folder\statistic\data\core\Filechecks.php:214]
#3 Piwik\Filechecks::getUserAndGroup(...) called at [x:\Folder\statistic\data\core\Filechecks.php:181]
#4 Piwik\Filechecks::getAutoUpdateMakeWritableMessage(...) called at [x:\Folder\statistic\data\plugins\CoreUpdater\Controller.php:83]
#5 Piwik\Plugins\CoreUpdater\Controller->newVersionAvailable(...) called at [:]
#6 call_user_func_array(...) called at [x:\Folder\statistic\data\core\FrontController.php:507]
#7 Piwik\FrontController->doDispatch(...) called at [x:\Folder\statistic\data\core\FrontController.php:84]
#8 Piwik\FrontController->dispatch(...) called at [x:\Folder\statistic\data\core\dispatch.php:34]
#9 require_once(...) called at [x:\Folder\statistic\data\index.php:47]

There is an error. Please report the message (Piwik 2.4.0) and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning: shell_exec(): Unable to execute 'groups | cut -f3 -d" "' in x:\Folder\statistic\data\core\Filechecks.php on line 219

Backtrace -->

#0 Piwik\Error::errorHandler(...) called at [:]
#1 shell_exec(...) called at [x:\Folder\statistic\data\core\Filechecks.php:219]
#2 Piwik\Filechecks::getUserAndGroup(...) called at [x:\Folder\statistic\data\core\Filechecks.php:181]
#3 Piwik\Filechecks::getAutoUpdateMakeWritableMessage(...) called at [x:\Folder\statistic\data\plugins\CoreUpdater\Controller.php:83]
#4 Piwik\Plugins\CoreUpdater\Controller->newVersionAvailable(...) called at [:]
#5 call_user_func_array(...) called at [x:\Folder\statistic\data\core\FrontController.php:507]
#6 Piwik\FrontController->doDispatch(...) called at [x:\Folder\statistic\data\core\FrontController.php:84]
#7 Piwik\FrontController->dispatch(...) called at [x:\Folder\statistic\data\core\dispatch.php:34]
#8 require_once(...) called at [x:\Folder\statistic\data\index.php:47]

Since my web server with Windows runs he does not know these Linux commands whoami and groups. You’d have to install a switch on which the OS is running Piwik. The update runs after successfully

Dany

it seems that whoami command is now available in windows since windows 2000 What is the Windows equivalent of Unix "whoami" command? - Server Fault

so it should work for most windows users out there, but maybe you are using older windows?

It’s Windows Server 2008 R2 (x86)

Sorry I can’t help further as I don’t have access to windows 2008. do you know why whoami is not available there?

maybe there is an alternative command we could use?

The command whoami should be available:

http://technet.microsoft.com/en-us/library/cc771299.aspx

Hi all, I’m new here and my apologies for not lurking. I too received two shell_exec() errors upon updating from 2.4.1 to 2.5.0, on IIS 8.0 (Windows Server 2012):


Warning: shell_exec(): Unable to execute 'whoami' in D:\www\example.com\www\piwik\core\Filechecks.php on line 232 
Warning: shell_exec(): Unable to execute 'groups | cut -f3 -d" "' in D:\www\example.com\www\piwik\core\Filechecks.php on line 219

Matt,
Now I wonder: what are you trying to accomplish using these functions? Looks like Filechecks.php is meant for checking if files and folders are writable and to provide a message to the user if it’s not. Given the error messages, the code isn’t really cross platform. Yes, ‘whoami’ is supported in Windows but hopefully not from within PHP/IIS/Fastcgi. A proper installed Windows/IIS instance doesn’t always allow exec(), shell_exec() and other potentially very dangerous cmd-functions, and IMO it’s not wise to only rely on Linux/Unix functions. ‘Groups’ and ‘cut’ are not supported on Windows. I think you can rely on $_ENV[“USERNAME”] or $_SERVER[“USERNAME”], for as far as it’s secure to rely on these variables. These’ll provide the Windows IUSR-account the website runs as.

You said earlier in this thread:

If you are in desperate need of a Windows Server / IIS test environment, I’d be happy to sponsor a Vevida Basic hosting package on a shared web server for Piwik development and testing (only FTP/FTPs uploads). Just drop me a note somewhere and I can provide some more details and/or set you up. Note though, September 3rd is my first working day due to vacation.

PS: Filechecks.php, lines 240 - 246: cacls is deprecated in favor of icacls on Windows Server 2008 and up.

What we would love to get is help from the Piwik Windows community to help us support IIS and solve issues, for example with pull requests. if you can help us achieve better reliability for Windows in Piwik please comment in this ticket: Test Piwik on IIS · Issue #6018 · matomo-org/matomo · GitHub

I’ll see what I can do when I return from my vacation.