Alexander Shinn on Fri, 9 Apr 1999 02:22:47 -0400 (EDT)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: setting TERM from a script

On Fri, Apr 09, 1999 at 12:10:09AM -0400, Jason Staloff wrote:
> When I log in to my ISP shell account from Linux, neither vi nor pine will
> work because TERM=linux. This being unacceptable, I set TERM=vt100; export
> TERM (my shell is bash), and it's fine for that session. So I'm thinking,
> what a great job for a little shell script...
> #!/bin/sh (yes that's where it is, I checked)
> TERM=vt100
> export TERM
> When I run it, there's no error but TERM is still linux. What's up?? I
> tried with #!/bin/bash, too, no dice.
> I also get the error from work logging in from Wind95's telnet client,
> which sets TERM=ansi. If I could get my sophisticated two-liner to work,
> I'd put it in .bash_profile and go on to live a happy life.

Environment variables aren't inherited from subshells, so TERM gets set
inside the script but resets when it ends.  You want to either source
the script so it takes place in the current shell, or just put the
settings in your .bash_profile.

> Bonus Question: while I was writing this, my telnet session on the PC
> timed out, and I couldn't get back to my local shell. ^z and ^d didn't
> help. I had to ctr-alt-del! The system shut down and came back up in
> an orderly fashion but it's really disturbing that such a thing was
> necessary. What could I have done to avoid rebooting? (This session
> was at the shell prompt, X wasn't running, so I couldn't use kill.)

^] is the escape sequence for telnet (chosen because you want to be able
to pass other control sequences like ^z to the client on the other end).

More importantly, Alt-F[1-6] will get you to a different virtual
terminal you can log into, and kill any process locking another


To unsubscribe, send a message with the word 'unsubscribe' in the subject
or body of your message to