"Tput: No Value for $Term and No -T Specified " Error Logged by Cron Process

tput: No value for $TERM and no -T specified error logged by CRON process

Something in the script is calling the tput binary. tput attempts to inspect the $TERM variable to determine the current terminal so it can produce the correct control sequences. There isn't a terminal when cron is running so you get that error from tput.

You can either manually assign a TERM value to the cron job (likely dumb or something similar to that) or (and this is likely the better solution) you can find out what is calling tput and remove that call.

tput: No value for $TERM and no -T specified when command run over ssh


Option One: Making ssh provide a TTY

Pass -tt to ssh to force it to provide a TTY, and pass TERM through explicitly if you don't trust ssh to be configured to do so implicitly:

#!/bin/bash
# ^^^^- the below printf usage is not available in baseline POSIX sh

printf -v term_q '%q' "$TERM"
ssh -t root@"$node_name" "TERM=$term_q bash -s" < ./script.sh

Of course, this only makes sense if your ssh is run from a terminal. If it's run from a cron job, then you need something different.


Option Two: Making Do Without One

The operation you're running is one that only makes sense in the context of a terminal. With no terminal, there doesn't exist a terminal width for tput to look up; and with no terminal type set via the TERM environment variable, there's no control sequence available for it to use.

Consider setting a default for noninteractive use:

# if we have no TERM, and no preexisting COLUMNS, set our own
[[ $TERM || $COLUMNS ]] || COLUMNS=80

...or writing your code to handle the case itself:

# skip this command altogether if we have no TERM or COLUMNS
[[ $TERM || $COLUMNS ]] && printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -

(Note that assigning to COLUMNS is not particularly well-defined behavior; some shells may not allow it; they're well within the POSIX specification to do so, as the shell and system utilities are allowed to make their own use of all-caps variable names; only lower-case names are guaranteed safe for other applications to use).

How can I intercept errors from gzip so cron doesn't see them?

I've not tested it, but something like:

  $gunzip_result=system("gunzip $gzfile 2>/dev/null");

Quicker syntax for Jenkins identical parallel stages

Please see below code which will create and run the stage on multiple agents:

// Define your agents
def agents = ['agent-1','agent-2','agent-3']

def createStage(label) {
return {
stage("Runs on ${label}") {
node(label) {
// build steps that should happen on all nodes go here
echo "Running on ${label}"
sh 'do task number 468'
}
}
}
}

def parallelStagesMap = agents.collectEntries {
["${it}" : createStage(it)]
}
pipeline {
agent none
stages {
stage('parallel stage') {
steps {
script {
parallel parallelStagesMap
}
}
}
}
}


More information is available at : Jenkins examples



Related Topics



Leave a reply



Submit