Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine telnet window size.

Status
Not open for further replies.

gawker

Programmer
Feb 21, 2002
34
US
I hope that this is the correct forum for this...

I'm writting a script that will list user data files in a directory. The script will allow the user to select the file using an associated number that is displayed next to the file name.

I want to control how many files (lines) are displayed based on the telnet window size (example: Using PCXware).

The smitty utility does the same sort of checking as you can't use smitty in a window that is less then 24 lines x 80 characters.

Is there a way to get the window dimensions?

Thank you.

Gawker
[trooper]
 
stty size

Dunno how portable that is, its what i use along with linux, dont remember if its working on *bsd.

usually the $LINES and $COLUMNS env vars show the dimension, but they aint exported so not accessable by scripts or processes.. a short zsh/bash one line to bring them back looks like the following

size=( `stty size` ) LINES=$size COLUMNS=${size[1]}

. Mac for productivity
.. Linux for developement
... Windows for solitaire
 
Take a look at tput lines and tput cols
You may also already have environment variables like LINES and COLUMNS

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you xmb,

I found that "stty -a" gives me the environmental variables I need in one of the lines:

speed 9600 baud; 24 rows; 80 columns;

From which I can then control my data return.

[thumbsup2]

Gawker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top