Tom Widland writes:
> Is there an introspective way to get the ip address of the computer
> running my ACL program, in either Unix or Windows?
>
> Thanks
>
This works under ACL/Linux:
USER(1): (defconstant +ifconfig+ "/sbin/ifconfig -a")
+IFCONFIG+
;;; change this string to whatever works on your Unix variant.
;;; there are Unixen about that won't even let you do this without
;;; being root
USER(11): (defun get-ip-address ()
(with-open-stream (stream (excl:run-shell-command +ifconfig+ :wait nil :output :stream))
(loop for line = (read-line stream nil nil)
while line
do
(format t "~A" line))))
GET-IP-ADDRESS
Note that you would have to parse the output instead of just
displaying it like I did. Also this will potentially give you heaps of
interfaces since you can easily have lo (loopback for 127.0.0.1), some
token ring interfaces, some ethernet interfaces, some slip and/or ppp
connections and some aliases if you're doing NAT. The concept of *the*
IP address of a machine is ill defined.
Lieven