Hi ,all:
I get a problem, when I want to get sub-a process output from the buffer.
Here is the code, in my .emacs:
(defun startup (check-command wanted start-command)
"check whether the 'wanted' state satisfied, if not, launch the start-command"
(interactive)
(save-excursion
(let* ((d-buf (get-buffer-create "diagnose"))
(process-connection-type nil)
(process-status (eval `(call-process (car check-command) nil d-buf t ,@(cdr check-command)))))
(print `(,(buffer-modified-p) ,(buffer-size) ,(point-min) ,(point) ,(point-max)) d-buf)
;;(debug)
(if (not (string-match wanted (buffer-string)))
(progn
(print (concat "starting command " (stringlist-to-string start-command " ")) d-buf)
(eval `(start-process "start up" d-buf (car start-command) ,@(cdr start-command)))
)
(print
(concat wanted " matched! no need to start " (stringlist-to-string start-command " ")) d-buf)
))))
(setq system-start-up-list
'((("sudo" "netstat" "-i") "eth0" ("sudo" "ifup" "eth0")))
)
;;(debug-on-entry 'startup)
(mapcar (lambda (ssup-item)
(let ((check-command (car ssup-item))
(wanted (cadr ssup-item))
(start-command (caddr ssup-item)))
(startup check-command wanted start-command))
) system-start-up-list)
Something strange is that, I get the following in my diagnose buffer:
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 3959 0 0 0 1903 0 0 0 BMRU
lo 16436 0 122 0 0 0 122 0 0 0 LRU
(nil 0 1 1 1)
"starting command sudo ifup eth0"
ifup: interface eth0 already configured
Process start up finished
It seems that , string
"
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 3959 0 0 0 1903 0 0 0 BMRU
lo 16436 0 122 0 0 0 122 0 0 0 LRU
" could not be read by the (buffer-string) :(
How can I solve the problem? thanks
cheers
--
YuGang