2

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?

Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178

1 Answers1

1

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;
}
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
  • 1
    on Ubuntu 12.04.4 LTS, i have not your params : --word-wrap --no-header $ aha -? Ansi Html Adapter Version 0.4.4 aha takes SGR-colored Input and prints W3C conform HTML-Code use: aha [-f file] aha (--help|-h|-?) options: --black, -b: Black Background --pink, -p: Pink Background --iso X, -i X: Uses ISO 8859-X instead of utf-8. X --title X, -t X: Gives the html output the title "X" instead of "stdin" or the filename --line-fix, -l: Uses a fix for inputs using control sequences to change the cursor position like htop. It's a hot fix, it may not work ... – Alban Aug 04 '14 at 20:26
  • 1
    Indeed, the `--word-wrap` was introduced in `0.4.5` (currently Ubuntu 12.04 use `0.4.4`) https://github.com/theZiz/aha/blob/master/CHANGELOG – Édouard Lopez Aug 05 '14 at 07:11