Skip to content

Instantly share code, notes, and snippets.

@ryrun
Last active August 29, 2015 14:15
Show Gist options
  • Save ryrun/1165d0e0135d23d4c6a0 to your computer and use it in GitHub Desktop.
Save ryrun/1165d0e0135d23d4c6a0 to your computer and use it in GitHub Desktop.
get IP and MX of a domain with Emacs
; get ip and mx
(let ((domain "mydomain.com"))
(switch-to-buffer-other-window "*temp*")
(erase-buffer)
(setq www (format "www.%s" domain))
(setq ip "")
(setq mx "")
(setq ret-val (call-process "ping" nil t nil domain "-n" "1"))
(if (equal ret-val 0)
(progn
(goto-char 1)
(setq ip (buffer-substring-no-properties
(search-forward "[") (- (search-forward "]") 1)))))
(erase-buffer)
(call-process "nslookup" nil t nil "-type=MX" domain)
(goto-char 1)
(if (search-forward "mail exchanger = " nil t)
(progn
(setq mx (thing-at-point 'filename))))
(other-window 1)
(print (concat "\t" ip "\t" mx)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment