tput

Bash - Clearing the last output correctly

允我心安 提交于 2020-06-08 18:04:21
问题 I'm trying to create an update-able progress status. In order to do that, I need to be able to clear the last output in its entirety so that I can update it. Carriage returns can work, but when the output is longer than the terminal width and wraps around, it will fail to clear the last output. So I'm using tput: n=0 while [[ $n -ne 100 ]]; do n=$((n+1)) tput ed #clear tput sc #save cursor echo -n "Progress: ${n}%" tput rc #restore cursor sleep 1s done echo But this will fail if the output is

Bash - Clearing the last output correctly

我的未来我决定 提交于 2020-06-08 18:04:08
问题 I'm trying to create an update-able progress status. In order to do that, I need to be able to clear the last output in its entirety so that I can update it. Carriage returns can work, but when the output is longer than the terminal width and wraps around, it will fail to clear the last output. So I'm using tput: n=0 while [[ $n -ne 100 ]]; do n=$((n+1)) tput ed #clear tput sc #save cursor echo -n "Progress: ${n}%" tput rc #restore cursor sleep 1s done echo But this will fail if the output is

Using column command on tput result over bash

孤人 提交于 2019-12-24 10:37:29
问题 I have a variable "x" , which contains two columns and two row. I wanted to print "hi" in RED color, so I took help of tput ,which printed the result in red. But I also needed to print the columns in proper alignment for that I used column -t but it is distorting the output. This was due to the fact that some control chars are added by tput. x="hello $(tput setaf 1)hi $(tput sgr0) whatsup hey howdy cya" echo "$x" hello hi whatsup hey howdy cya echo "$x"|column -t hello hi whatsup hey howdy

How do I get colored output to a file from a bash script running in crontab?

一个人想着一个人 提交于 2019-12-22 12:52:31
问题 When I run a bash script manually, the output appends my log file in the color specified using tput. When I run the bash script as a cronjob, the output loses the color. Thanks. 回答1: Your cron environment almost certainly is just not specifying a terminal type that supports colors and so tput is not returning anything. Compare: $ echo $TERM xterm-256color $ printf %q\\n "$(tput setaf 5)" $'\E[35m' $ printf %q\\n "$(TERM=dumb tput setaf 5)" '' 回答2: I put TERM=xterm export TERM in the bash

Docker number of lines in terminal changing inside docker

落花浮王杯 提交于 2019-12-17 22:33:50
问题 I would like to know how to change the following behavior. Let's say my terminal has 28 lines. Then I use the following commands: $ tput lines # my terminal 28 $ docker run --rm -it ubuntu:16.04 tput lines # docker container 24 ## WHY?? $ docker run --rm -it ubuntu:16.04 bash # docker container inside command root@810effa2777c:/# tput lines 28 As you can see, even when all the results should be 28 , when I'm calling the container as docker run --rm -it ubuntu:16.04 tput lines it always gives

How do I get colored output to a file from a bash script running in crontab?

不问归期 提交于 2019-12-06 10:29:35
When I run a bash script manually, the output appends my log file in the color specified using tput. When I run the bash script as a cronjob, the output loses the color. Thanks. Your cron environment almost certainly is just not specifying a terminal type that supports colors and so tput is not returning anything. Compare: $ echo $TERM xterm-256color $ printf %q\\n "$(tput setaf 5)" $'\E[35m' $ printf %q\\n "$(TERM=dumb tput setaf 5)" '' I put TERM=xterm export TERM in the bash_profile file and the colors are working. 来源: https://stackoverflow.com/questions/25512588/how-do-i-get-colored-output

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

a 夏天 提交于 2019-12-05 15:42:32
问题 We have a shell script which is run by CRON. The shell script in turn runs a python script which downloads files from an FTP server and then runs a java log processor on those files. The process runs just fine, except that I keep on getting CRON emails even if there is no error. At least, I think there is no error. The cron email has two lines, out of which one of the lines is tput: No value for $TERM and no -T specified After researching a bit, I found that it's something to do with setting

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

[亡魂溺海] 提交于 2019-12-04 02:31:49
We have a shell script which is run by CRON. The shell script in turn runs a python script which downloads files from an FTP server and then runs a java log processor on those files. The process runs just fine, except that I keep on getting CRON emails even if there is no error. At least, I think there is no error. The cron email has two lines, out of which one of the lines is tput: No value for $TERM and no -T specified After researching a bit, I found that it's something to do with setting the $TERM variable. I am not sure, how to do that. Any help would be appreciated. Thanks! Something in

Docker number of lines in terminal changing inside docker

陌路散爱 提交于 2019-11-28 18:13:01
I would like to know how to change the following behavior. Let's say my terminal has 28 lines. Then I use the following commands: $ tput lines # my terminal 28 $ docker run --rm -it ubuntu:16.04 tput lines # docker container 24 ## WHY?? $ docker run --rm -it ubuntu:16.04 bash # docker container inside command root@810effa2777c:/# tput lines 28 As you can see, even when all the results should be 28 , when I'm calling the container as docker run --rm -it ubuntu:16.04 tput lines it always gives me 24 despite the size of my terminal. This is not only with the ubuntu container, I also tried with