Console/SSH/X: How to tell?

Chris F.A. Johnson cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org
Fri Jun 19 20:31:15 UTC 2009


On Fri, 19 Jun 2009, Marc Lanctot wrote:
>
> I use pal for my calendaring now and I'd like my xterms to open up with
> the output from pal. However, if I add it to .bashrc, then when I try
> to copy things to/fro remotely scp fails because there is output
> generated by my .bashrc.
>
> So what I'd like to do is detect if the session is an xterm/console, or
> through interactive ssh.. and output the calendar in these cases but
> not in cases where I scp or execute a command remotely.
>
> Can I do this? If so, how?

if [ -t 0 ] ## if connected to a terminal
then
   : ...
fi

-- 
    Chris F.A. Johnson                      <http://cfaj.freeshell.org>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list