Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

information in xterm's title & tcsh & less

Posted on 2000-03-04
7
Medium Priority
?
661 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.
Suggested Courses

718 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