help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Empty buffer


From: Kevin Rodgers
Subject: Re: Empty buffer
Date: Mon, 06 Feb 2006 12:04:13 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

BRUCE INGALLS wrote:
What I am trying to do, is grab the first IP address, which is not a
netmask, nor 127.0.0.1.
Here is my first attempt:

  (require 'net-utils)
  (save-excursion
    (ipconfig)
    (set-buffer "*Ipconfig*")
    (goto-char (point-min))
    (search-forward-regexp "[0-9]" nil t)
    (match-beginning 1)))

Unfortunately, I cannot capture the output of ipconfig():

  (save-excursion
    (ipconfig)
    (set-buffer "*Ipconfig*")
    (buffer-string)))

That's because ipconfig uses start-process (via net-utils-run-program)
to run netstat-program as a subprocess, and its complete output is not
immediately available.  But since net-utils-run-program returns the
buffer:

(save-excursion
  (let* ((ipconfig-buffer (ipconfig))
         (ipconfig-process (get-buffer-process ipconfig-buffer)))
    (while (eq (process-status ipconfig-process) 'run)
      (sit-for 0 10 t))
    (set-buffer ipconfig-buffer)
    (buffer-string)))

--
Kevin Rodgers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]