Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if connected to remote server?

Tags:

emacs

elisp

tramp

I use tramp to connect to my company's servers. I would like to customize my functions to work differently if I am accessing local files vs remote ones.

Is there a variable I could check if the buffer I am accessing is on a remote server or my local machine?

Something like:

if(TRAMP_CONNECTED)
 Do this
else
 Do that
like image 496
SFbay007 Avatar asked Feb 22 '15 01:02

SFbay007


People also ask

How do I see who is connected to my remote server?

First option - use command line to "query user /server:SERVERNAME" (or "quser.exe" - same thing). This shows User name, Session name, Session Id, Session state, Idle Time and Logon Time for all logged in users.

How can I tell if my server is online remotely?

A ping from outside the remote network to the public IP address will tell you if the internet is up and the remote firewall is working. A ping from inside the remote network will tell you if the intranet is up and if the server is responding. If you can't ping it, then the server or the network is down.


1 Answers

The most robust check is likely default-directory. This variable is always set buffer local. If (file-remote-p default-directory) returns non-nil, your buffer is under Tramp control.

like image 186
Michael Albinus Avatar answered Oct 10 '22 09:10

Michael Albinus