KBEC-00039 - Apache and ElectricCommander session ID under Linux

Article ID:360032832312
2 minute readKnowledge base


When creating your own GUI using Apache, you may want to use ElectricCommander ectool commands. The ectool login command fails when executed as Apache under Linux with the following response:

"Login failed. ["Couldn't write session file: Permission denied"]"


ectool login, by default, creates in the user’s Home directory a .ecsession file containing the session ID, or token.

The token is:

  1. Held on the Commander server

  2. Expired on the Commander server after:

    1. 72 hours (3 days) of no use. Using the token resets the timer.

    2. each server restart

  3. Stored on the client in a file in a directory that is unique to:

    1. the OS user - each user has a unique .ecsession file

    2. the host - can have a different .ecsession file on a different host

    3. the Commander server - each session to a different Commander server has a different token

The default .ecsession file is located in the user’s space.

  1. On Windows

    1. Windows Vista, Windows7, by default, for user "build": "C:\Users\build\AppData\Local\Electric Cloud\ElectricCommander"

    2. Windows XP and 2003 by default, for user "build": "C:\Documents and Settings\build\Local Settings\Application Data\Electric Cloud\ElectricCommander".

  2. On Linux, by default, "~/.ecsession".


The issue is that processes running as "nobody", such as those started by Apache, do not have write access to their own Home directory.

ectool has a means to override this location by using the environment variable COMMANDER_SESSIONFILE, which can direct ectool to store the session file in a different location.


Use the following code to set an alternate session ID location and check the result of the ectool login command.

$ectool = "/opt/electriccloud/electriccommander/bin/ectool \--server $ecserver ";
$cmd = "$ectool login admin changeme";
$login_output = system($cmd, $return_code);
echo "Login Successful?
echo " Ouput = $login_output
echo " Return Code = $return_code