Solved

information in xterm's title & tcsh & less

Posted on 2000-03-04
7
616 Views
Last Modified: 2008-03-10
to have a computer name and path on the title
of xterm i do have following in my .tcshrc:

if ($?TERM) then
  alias monas_private_title   'echo -n "\033]0;`hostname`:`pwd`\007"'

  alias cd 'cd \!*; monas_private_title'
#  monas_private_title # <---- mark
endif

if I uncomment marked line and try to "less some_file" - I get one line with ESC and no text of that some_file.

if I leave as it is - I don't get info until first cd.

Question: Why do I get that crap? How do I have information right after login.

info about sw (if that matters)
tcsh: version tcsh 6.08.00 (Astron) 1998-10-02 (i586-intel-linux) options 8b,nls,dl,al,color

xterm: AIX 4.3.3

connection: ssh-1.2.27
0
Comment
Question by:monas
  • 3
  • 3
7 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2583370
Which is the local machine and which is the remote that the .tcshrc file is on?
If you open an xterm on the remote and issure the command "echo -n "\033]0;`hostname`:`pwd`\007" what happens?
0
 
LVL 3

Author Comment

by:monas
ID: 2583642
OK, that was when AIX runs X+xterm, linux - tcsh.

But right now I have checked on another linux box where X, xterm adn tcsh runs on the same machine. Results:

when I have monas_private_title in .tchsrc - I get

ESC]0;ak:/home/kaspar^G
/etc/passwd line 1/1 (END)

to "less /etc/passwd"

when title line is missing - I get less working. **Even** if I enter manually this command before issuing less!

What's going on?!?!
0
 
LVL 3

Author Comment

by:monas
ID: 2583646
Oh, linux in both cases is slackware 7 with 2.2.14 kernel
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 40

Expert Comment

by:jlevie
ID: 2583662
Can I see your entire .tcshrc file, please? You can paste it into a comment ore email it to jlevie@bellsouth.net.
0
 
LVL 40

Accepted Solution

by:
jlevie earned 150 total points
ID: 2585686
Okay, what I thought was probably happening was that the highly non-portable behaviour of echo was at the root of the problem, but I wanted to see your .tcshrc to make sure.

The behavour of echo for anything except plain strings varies according to platform and shell and shell implementation. The correct way, when using more than one platform is to carefully collect each thing that's OS or shell version dependant into a section that's only used for that particular OS.

I've put a template of such a shell init file below that you can fill in with what you need in the appropriate sections. It may have a typo or two in it as I stripped a bunch of stuff out of an existing .cshrc. Note the different ways I've defined the "title" command for those OS's I could easily check.

--- Begin template ---
#
# Figure out what OS this is
#
switch (`uname -s`)
  case SunOS:
    switch (`uname -r`)
      case 5.*:
        setenv OS SOLARIS
        switch (`uname -p`)
          case sparc:
            setenv CPU SPARC
            breaksw
          case i386:
            setenv CPU INTEL
            breaksw
        endsw
        breaksw
      case 4.1.3_U1:
        setenv OS SUNOS
        breaksw
    endsw
    breaksw

  case Linux:
    setenv OS LINUX
    breaksw

  case IRIX:
    setenv OS IRIX
    setenv CPU IRIX32
    breaksw

  case IRIX64:
    setenv OS IRIX
    setenv CPU IRIX64
    breaksw

  default:
    echo "Who knows what OS this is"
endsw

#
# Do platform specific & generic setups (path, env vars, etc.)
# other than what's needed for an interactive shell
#
switch ($OS)
  case SOLARIS:
    alias title '/bin/echo "\033]0;`hostname`:pwd`\007\c"'
    setenv path (....)
    setenv MANPATH (...)
    setenv LD_LIBRARY_PATH (...)
    ...
    breaksw
  case SUNOS:
    setenv path (....)
    setenv MANPATH (...)
    setenv LD_LIBRARY_PATH (...)
   ...
   breaksw
  case LINUX:
    alias title '/bin/echo -n -e "\033]0;`hostname`:pwd`\007"'
    setenv path (....)
    setenv MANPATH (...)
    setenv LD_LIBRARY_PATH (...)
    ...
    breaksw
  case IRIX:
    alias title '/bin/echo -n "\033]0;`hostname`:pwd`\007"'
    setenv path (...)
    ...
    breaksw
  case IRIX64:
    alias title '/bin/echo -n "\033]0;`hostname`:pwd`\007"'
    setenv path (...)
    ...
    breaksw
endsw
#
# Some generic applicable to all platforms
#
umask 002
....

#
# Only execute what follows for interactive shells
#
if ($?USER == 0 || $?prompt == 0) then
  exit
endif

set history = 32
set savehist = 32
set prompt = "AK@%m( \! )%.03 %#%#"                                            ...

#
# A few generic aliases and the OS dependant ones
#
alias ls 'ls -F'
if ($?TERM) then                                                                  alias cd 'cd \!*; title'
   title
endif                                                                          ...

switch ($OS)
  case SOLARIS:
    setenv LESS -cej1s
    alias more less
    alias psg 'ps -ef | fgrep \!* | fgrep -v fgrep'
    switch ($CPU)
      case SPARC:
        setenv FMHOME /opt/Frame
        alias maker '$FMHOME/bin/maker'
      breaksw
    endsw
    ...
    breaksw

  case SUNOS:
    ...
    breaksw

  case Linux:
    setenv LESS -cej1s
    alias psg 'ps -ef | fgrep \!* | fgrep -v fgrep'
    ...
    breaksw

  case IRIX:
    setenv LESS -cej1s
    alias more less
    alias psg 'ps -ef | fgrep \!* | fgrep -v fgrep'
    ...
    breaksw

  case IRIX64:
    setenv LESS -cej1s
    alias more less
    alias psg 'ps -ef | fgrep \!* | fgrep -v fgrep'
    ...
    breaksw
endsw

#
# If I have a host rc file execute it now. This gives
# me a place to put stuff that's specific to a particular
# host.
#
if (-f $HOME/.host_csh) then
  source $HOME/.host_csh
endif
0
 

Expert Comment

by:vrmuds
ID: 2588360
I think you are looking for this:
This works under korn, and changes a little for different shells.
^v]2;ak:$PATH^g >
or
CNTL-[]2;whateverCNTL-g
One of these will work.
0
 
LVL 3

Author Comment

by:monas
ID: 2589137
Thank you jlevie!

The problem was that I missed to exit before interactive stuff in not interactive shells. It happened that LESSPIPE was set somewhere in host-wide config; it's value was "|lesspipe.sh" and I suspect that seeing | less put all the job to new instance of shell. less shows original file only in case when lesspipe outputs nothing, but in my case my shell startup had outputed title - therefore things were bad.

Thanks again for pointing out how to write correct startup files!

All the best
      -- monas
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now