Search code examples
phpcodeignitershellexectput

PHP tput: No value for $TERM and no -T specified


I'm having the following error when using the exec() function:

string(25) "/etc/init.d/mast list-log" 
array(1) { [0]=> string(44) "tput: No value for $TERM and no -T specified" } 
tput: No value for $TERM and no -T specified

My command is /etc/init.d/mast list-log and was working prior to reboot. I can't see what the difference.

Source code

public static function execute($_ = null, $debug=true) {
    $_ = $debug ? $_." 2>&1"  : $_;
    exec("$_ | aha --word-wrap --no-header", $output, $exitCode);
    return $output;
}

Question

Do you have suggestion on how to solve this?


Solution

  • In shell you can set an environment variable that has the life cycle of the following command as follow:

    TERM=screen-256color ls -l --color=always
    

    Where TERM=screen-256color is the environment variable and ls -l --color=always the command.

    Solution

    Here is my modified code, I simply prepend TERM=screen-256color to my command:

    public static function execute($_ = null, $debug=true) {
        $_ = $debug ? $_." 2>&1"  : $_;
        exec("TERM=screen-256color $_ | aha --word-wrap --no-header", $output, $exitCode);
        return $output;
    }