[Geek] F*^#!!!!!
May. 19th, 2005 01:30 pmHow do you work out how many lines are on the screen when you're in a script in linux??
At the command line you can simply do 'echo $LINES', but in a script the LINES environment variable is no longer available. I can't work it out!!!
Someone help me before I go mad!
At the command line you can simply do 'echo $LINES', but in a script the LINES environment variable is no longer available. I can't work it out!!!
Someone help me before I go mad!
no subject
Date: 2005-05-19 12:54 pm (UTC)Sorry, that's probably not much help.
no subject
Date: 2005-05-19 01:31 pm (UTC)xterm, but I agree with you that I think the reason is because you can't guarantee you're running the script from a shell. But there must still be a way to discover it if you are!!no subject
Date: 2005-05-19 01:18 pm (UTC)Find out which program that is, and use it in your script. My guess is that the program in question is resize, which it's worth noting only gets you the information you want when you're running in an xterm or something compatible.
Alternatively, export LINES. If it's already exported, find out what's stripping your script's environment. (-8
no subject
Date: 2005-05-19 01:40 pm (UTC)bash- thebashman page says:LINES Used by the select builtin command to determine the column length for printing selection lists. Automatically set upon receipt of a SIGWINCH.So I tried sending the current terminal a SIGWINCH from within the shell but it didn't make it available. Googling forLINESor$LINESor derivations is worse than useless.I think
no subject
Date: 2005-05-19 02:01 pm (UTC)resizecommand seems to give me back my variables ;)echo `resize`gives
COLUMNS=80; LINES=24; export COLUMNS LINES;no subject
Date: 2005-05-19 02:21 pm (UTC)LINES=`resize | grep LINES= | grep -Po '\d+'`no subject
Date: 2005-05-20 08:05 am (UTC)no subject
Date: 2005-05-19 01:30 pm (UTC)*Hides*
no subject
Date: 2005-05-19 01:41 pm (UTC)The reason it needs to be done programmatically is of course that the end user can (and will want to) resize the screen to view more output. It's only a silly little program but I can't believe it's so difficult!
no subject
Date: 2005-05-20 08:41 pm (UTC)