Console/SSH/X: How to tell?

Andrej Marjan amarjan-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org
Sat Jun 20 01:02:28 UTC 2009


On June 19, 2009 03:36:40 pm Marc Lanctot wrote:
> Hello,
>
> 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?
>
> Thanks in advance,
> Marc

I have this at the top of my .bashrc, but I don't remember where I picked it 
up. I do know it's a pretty common idiom:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

$PS1 is the variable that holds the primary prompt -- it's only set for 
interactive shells.
--
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