You are not logged in.

#1 2011-09-22 17:05:56

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

[Solved] Listing Remote Logins

I have a few lines in my .bashrc that only work if an X server is running, the problem is that whenever I ssh into my box those commands run, fail and puke them to the console. I know I can write a conditional statement for this but I can't find the command to use to check to see if a login is graphical or CLI based.

solution:
if [[ ! -z "$SSH_CONNECTION" ]]
  then
     stuff that you only want to run when the connection is local
fi

Last edited by brando56894 (2011-09-22 19:26:47)

Offline

#2 2011-09-22 17:43:59

jakobm
Member
Registered: 2008-03-24
Posts: 132

Re: [Solved] Listing Remote Logins

Check  $TTY (/dev/tty* vs. /dev/pts*) or if $SSH_CONNECTION is set. Checking $DISPLAY is possible, too.

Last edited by jakobm (2011-09-22 17:44:58)

Offline

#3 2011-09-22 19:19:47

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Listing Remote Logins

Thanks!

Offline

Board footer

Powered by FluxBB