You are not logged in.

#1 2011-01-01 01:42:12

pogeymanz
Member
Registered: 2008-03-11
Posts: 1,020

How can my machine check if I'm logging in remotely (ssh) or not?

In my .bash_profile I have startx because I'm lazy.

But when I'm logging in via ssh (a new thing for me), this obviously causes problems.

What bash logic can I use to check and see if I'm logging in locally or remotely?

Offline

#2 2011-01-01 01:44:05

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: How can my machine check if I'm logging in remotely (ssh) or not?

$ who

??

Offline

#3 2011-01-01 02:00:31

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,680

Re: How can my machine check if I'm logging in remotely (ssh) or not?

If you are logging in remotely via ssh then $(tty) will evaluate to something like /dev/pts/0 as opposed to /dev/tty1 when you are logging in locally.  You could add something like this to your .bash_profile

if [[ $(tty) = /dev/tty1 ]] && [[ -z "$DISPLAY" ]]; then
  startx
  logout
fi

Offline

#4 2011-01-01 02:03:35

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,362

Re: How can my machine check if I'm logging in remotely (ssh) or not?

@pogeymanz, you're not new here but your recent posts have been relatively simple things that should be searched out rather than asked about one-after-another on the forums. Closing.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

Board footer

Powered by FluxBB