Resizing Terminal Size Upon Login?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Resizing Terminal Size Upon Login?
# 1  
Old 01-30-2015
Resizing Terminal Size Upon Login?

Hello All,

PC: CuBox-i
OS: OpenSuSE 13.1
uname: Linux CuBox 3.14.14-cubox-i #1 SMP Sat Sep 13 03:48:24 UTC 2014 armv7l armv7l armv7l GNU/Linux
Shell: Bash

So I was trying to see if there was a way to resize the terminal dynamically upon logging into a remote PC. How I login now is to use minicom on my PC (*or could be Putty from Windows depending on where I am) and Dial into the PC remotely. On the remote PC I have mgetty running to listen for and initialize the connection. I have mgetty configured to use TERM=vt102 as the Terminal type (*this is because this terminal produced the best result for using the screen command while dialed into this PC)...

Once I'm logged in I can see $COLUMNS is set to 80 and $LINES is set to 24.

I know I can change this by default in /etc/termcap, but who knows what size "My" terminal will be on my laptop before dialing into the PC. So I wanted to do it dynamically. I was able to successfully run the resize command which sets COLUMNS and LINES to the current window size and exports the variables after logging-in... So I was wondering if there is a way to run this automagically after logging in?

I read there is a file called "/etc/csh.login" that is supposed to get executed upon logging in, but looking over the file it doesn't even look like it would execute given the syntax of the code...
*For example, it has this in csh.login, which is not in any shell syntax I'm used to...
# Initialize terminal
if ( -o /dev/$tty && -c /dev/$tty && ${?prompt} ) then
    # Console
    if ( ! ${?TERM} )           setenv TERM linux
    if ( "$TERM" == "unknown" ) setenv TERM linux
    if ( ! ${?SSH_TTY} && "$TERM" != "dumb" ) then
        path stty sane cr0 pass8 dec
        path tset -I -Q
    # on iSeries virtual console, detect screen size and terminal
    if ( -d /proc/iSeries && ( $tty == "tty1" || "$tty" == "console")) then
        setenv LINES   24
        setenv COLUMNS 80
        eval `path initviocons -q -e -c`
    settc km yes
unsetenv TERMCAP

Given just the 1st If statement above, it fails with an error... Which got me wondering if csh.login was only for CSH/C Shell.?
Or maybe I can do something from ~/.bashrc file..?

Also, when I dial into the PC now, after I login and get the Command prompt the terminal size is working at the same physical size of the terminal window, but as soon as I use something like vi, view, man, etc... The terminal switches to 24 rows and 80 cols, which remains that way even after exiting those commands. But if the variables COLUMNS and LINES are set to what I want the size does NOT change.

But anyway, does anyone know what the best way to try and do this would be? Any thoughts or suggestions would be greatly appreciated!

Thanks in Advance,
# 2  
Old 01-31-2015
You are right, bash wouldn't touch csh.login. man bash:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/pro‐
file, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from
the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may
be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.
So - put your resize command in one of those and check after the next login.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 01-31-2015
Hey RudiC, thanks for the reply..

Ohhh ok cool. Don't know why those files didn't come to me, but now that you say that I think I can get that working, thanks!

I'll give it a go on Monday and I'll post back with my result.
Thanks again for the reply, very much appreciated!

# 4  
Old 02-02-2015
Perfect, worked like a charm!

Thanks again for the help, much appreciated!

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Unable to login in ssh terminal

Hi guys when ever i tried to connect aix server in my institute through ssh terminal the pop is coming like network is unreachable .Am using MacBook air the other guys who are using putty software in windows they can easily login in tho the server through remotely . Is there any one can... (3 Replies)
Discussion started by: aashishb007
3 Replies

2. AIX

AIX 7.1 Login Terminal

Hi there, I am a newbie in AIX. I have reboot the AIX today and then the CDE login screen disappear. :eek:I have reboot several times and still it only shows the terminal (lft0) with only green characters and black screen:confused:. Anyway I can have the CDE login screen back?:confused: Also, as... (5 Replies)
Discussion started by: sunnytai
5 Replies

3. OS X (Apple)

How to prompt for login on OSX when starting Terminal

I was wondering if anyone can tell me how to log back in to unix after logging out. I have a MBPro. If I don't have the window close after exiting, then there is the phrase 'process completed' in brackets with a blinking cursor, but I can't type anything in. Is it also possible to start the... (4 Replies)
Discussion started by: Straitsfan
4 Replies

4. Red Hat

terminal size

Is there an easy command to know the size of a terminal window from a command line command? (3 Replies)
Discussion started by: garethsays
3 Replies

5. Shell Programming and Scripting

size of the terminal window

Hi, I am programming a script that shows a figure on screen but I would be centered, so What I have to use command to get the size of the window? Thanks a lot, (2 Replies)
Discussion started by: Gengis-Kahn
2 Replies

6. Shell Programming and Scripting

Remote Login in to another Terminal

hi all , i need the command for remote login in to another terminal, came accross by using "tty" command. please suggest and help me out in this. Regrds Sridhar. (1 Reply)
Discussion started by: Sridhar_dev
1 Replies

7. Solaris

Login from X-terminal

I have a Solaris 8 system acting as a NIS slave. My /etc/nsswitch.conf file specifies passwd: files nis and in general users can login successfully. However, I have a few users who use X-terminals booted off the Solaris box and these people are unable to login unless they have entries in the... (0 Replies)
Discussion started by: Scrollon
0 Replies

8. Solaris

How to allow root login from a specified terminal ?

I want to enable root login just from one terminal machine, can i do that via /etc/default/login in console=/dev/console line ? and if so what i have to type exactly, another question is it normal to edit the files inside defaults directly ? or i can copy it to /etc/ and edit it there and its... (3 Replies)
Discussion started by: XP_2600
3 Replies

9. Shell Programming and Scripting

expanding standard terminal size

what is the Ksh syntax to expand/change the geometry of the running terminal window? thanks (6 Replies)
Discussion started by: prkfriryce
6 Replies

10. UNIX for Dummies Questions & Answers

won't allow root login from another terminal to my sun

I'm trying to log in to one of my sun boxes via EXCEED's X-terminal and it won't allow me to do so as root, says not at system console, is there a way to change that so it allows logging in as root at a remote terminal? (3 Replies)
Discussion started by: kymberm
3 Replies
Login or Register to Ask a Question

Featured Tech Videos