LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-16-2009, 12:22 PM   #1
davender84
Member
 
Registered: Feb 2009
Posts: 42

Rep: Reputation: 15
Smile problem regarding tput cols


there is a command "#tput cols"
when i run this command in cli mode or linux terminal it gives result as 80
but i know that "#tput cols" is same as "#tput -Tlinux cols" because in "#tput cols" the value of terminal type is picked up from envoirement variable "TERM" (#echo $TERM) so both the above command should give the same result
but they give different resuls
#tput cols
80
#tput -Tlinux cols
-1
i think the later one is correct because there is no capability named "cols" is defined for linux terminal in terminfo database(#infocmp)
so "tput cols" should give the same result as -1 as "tput -tlinux cols"
does
pls help me why this command #tput cols runs prperly in linux terminal
 
Old 05-16-2009, 12:35 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,498

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Code:
-Ttype indicates  the  type  of  terminal.   Normally this option is unnecessary, because the
       default is taken from the environment variable TERM.  If -T  is  specified,  then  the
       shell variables LINES and COLUMNS will be ignored and the operating system will not be
       queried for the actual screen size.
I don't know why, but it is quite clear. If you want columns or rows, don't use -Ttype!
 
Old 05-16-2009, 12:44 PM   #3
davender84
Member
 
Registered: Feb 2009
Posts: 42

Original Poster
Rep: Reputation: 15
Smile hi

Quote:
Originally Posted by colucix View Post
Code:
-Ttype indicates  the  type  of  terminal.   Normally this option is unnecessary, because the
       default is taken from the environment variable TERM.  If -T  is  specified,  then  the
       shell variables LINES and COLUMNS will be ignored and the operating system will not be
       queried for the actual screen size.
I don't know why, but it is quite clear. If you want columns or rows, don't use -Ttype!
i simply know that tput cols should not run in cli mode because this capability is not supported by linux terminal so why this commands run and give proper result as 80
 
Old 05-16-2009, 12:52 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,498

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Why not? There is no mention of that in the termutils manual. tput cols can be used even in a script like this:
Code:
#!/bin/bash
COLUMNS=`tput cols` export COLUMNS # Get screen width.
echo "$@" | awk '
{ spaces = ('$COLUMNS' - length) / 2
  while (spaces-- > 0) printf (" ")
  print
}'
(from the cited manual). This prints a string at the center of the terminal.
 
Old 05-16-2009, 01:00 PM   #5
davender84
Member
 
Registered: Feb 2009
Posts: 42

Original Poster
Rep: Reputation: 15
Smile hi

Quote:
Originally Posted by colucix View Post
Why not? There is no mention of that in the termutils manual. tput cols can be used even in a script like this:
Code:
#!/bin/bash
COLUMNS=`tput cols` export COLUMNS # Get screen width.
echo "$@" | awk '
{ spaces = ('$COLUMNS' - length) / 2
  while (spaces-- > 0) printf (" ")
  print
}'
(from the cited manual). This prints a string at the center of the terminal.
when u use a particular terminal like linux or xterm all capabilities that these terminals have should be defined in terminfo database otherwise it will not run
 
Old 05-16-2009, 01:06 PM   #6
davender84
Member
 
Registered: Feb 2009
Posts: 42

Original Poster
Rep: Reputation: 15
Smile hi

Quote:
Originally Posted by davender84 View Post
when u use a particular terminal like linux or xterm all capabilities that these terminals have should be defined in terminfo database otherwise it will not run
i know that tput cols command runs in cli mode and gives the right result
but it should not run in cli mode because there is no capability named "cols" defined for linux terminal in terminfo database and u can check it by using command "#infocmp linux" and look in second row for the numeric capability
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
use of over strike with tput davender84 Linux - General 9 06-15-2009 04:25 AM
tput davender84 Linux - General 2 02-27-2009 03:33 AM
Cols. Ohio native RH/Fedora User for 7 years linuxfed5 LinuxQuestions.org Member Intro 1 04-16-2006 11:05 AM
Setting Nano to wrap at 72 cols, fails macondo Debian 2 11-09-2004 12:18 PM
text mode resolution (changing rows and cols) jaylee Linux - General 3 06-22-2003 08:16 PM


All times are GMT -5. The time now is 03:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration