We're updating the issue view to help you get more done. 

Automatic detection of utilities in path.

Description

All system utilities used by CA and available in PATH can be automatically located for both Windows and Posix systems using something like this ('where' is available on Windows 2003+; use executable name without extension, and a fully qualified path should be returned for Windows and Posix):

  1. Goes into setup.php
    if (defined('PHP_WINDOWS_VERSION_BUILD')) {
    define('_CA_SYSTEM_WINDOWS_', true);
    }

public static function getExecutable($name) {
if (_CA_SYSTEM_WINDOWS_) {
$cmdWhich = 'where ' . $name;
} else {
$cmdWhich = 'which ' . $name;
}

putenv('Path=' . getenv('Path')); // Somehow, only after this statement is executed, the environment variable PATH is updated with components added by SetEnv in Apache conf files.
$executablePath = shell_exec($cmdWhich);

if ($executablePath) {
$executableCache[$name] = $executablePath;
return $executablePath;
} else {
$executableCache[$name] = false;
return false;
}
}

$tool_name = 'exiftool';
getExecutable($tool_name);

Environment

Windows 7, Bitnami WAMP

Activity

Show:
User known
November 29, 2017, 7:07 AM

I'm not sure that relying upon an exec() to a command that is usually – but not always – present to get around setting a few paths is a good tradeoff. I'm more than willing to listen to arguments that I am wrong however. Is the current implementation causing real problems for you?

oper251
November 29, 2017, 9:22 AM

I am not sure what you are talking about. exec() is one of the core functions. If you can't execute a shell command, how would you be able to call those utils anyway? Besides, of course it is already used in the current implementation. Except there is no attempt to automatically locate those tools. If the tools is in the path, which is a reasonable assumption, it should be detected automatically, rather then make it necessary to edit all those paths.

Assignee

Seth

Reporter

oper251

Labels

None

Components

Affects versions

Priority

Minor
Configure