Thanks again.  I would never have thought of that.

It is getting closer but still not quite there.  With my point just after
the defun of shell-command-to-string I did c-x c-e.  Then I did c-x c-e
right after (shell-comment-to-string "echo hello").  I got "hello^J" in
my minibuffer but alas not in my file buffer.  So, all I need now is the
incantation for a defun which puts the output in the file buffer and not
the minbuffer.

Thanks,

Bill

btw, I got analogous results when I tried the analogous thing
with...

(shell-command "echo Testing")
(save-excursion
    (set-buffer "*Shell Command Output*")
        (buffer-substring (point-min)
                                    (point-max)))





On Thu, 11 Dec 2003, Anthony Liguori wrote:

> Actually, after googling a little, I discovered XEmacs has a
> (shell-command-to-string) function.  For GNU Emacs, you could just use
> something like:
>
> (defun shell-command-to-string (command)
>   (with-output-to-string
>     (call-process shell-file-name nil (list standard-output nil)
>           nil shell-command-switch command)))
>
> Regards,
> Anthony Liguori
>
> William L. Jarrold wrote:
>
> >Thanks a bunch.  Trouble is I get 0 returned.  I wished
> >I got the string ...
> >
> >   echo Testing shell command
> >
> >..returned.
> >
> >Hmm, how to deal with the returned value issue.  See
> >here is the problem...I just did...
> >
> >(shell-command "echo Testing")<meta-x pretty-print-eval-of-last-sexp>
> >
> >...and I got a 0 as the returned value but for the first few
> >tries but not the last few, "Testing" was printed out not in my main
> >buffer but in a spontaneously created split emacs window.  Any ideas on
> >how to get the printed shell output to be the returned value of the
> >elisp expression?
> >
> >(BTW, you get similar results with the less arcane meta-x eval-sexp)
> >
> >Thanks,
> >
> >Bill
> >
> >p.s. (shell-command "hi")<meta-x pretty-print-eval-of-last-sexp>
> >returns 127.
> >
> >Hmmm.  127 must be some kind of unix error code?
> >
> >
> >
> >>On Thu, 11 Dec 2003, Anthony Liguori wrote:
> >>
> >>
> >>
> >>>(shell-command "echo Testing shell command")
> >>>
> >>>Regards,
> >>>Anthony Liguori
> >>>
> >>>William L. Jarrold wrote:
> >>>
> >>>
> >>>
> >>>>Hi,
> >>>>
> >>>>Does anyone out there know how to call a shell program
> >>>>(in this specific case I want to call a perl function)
> >>>>
> >>>>
> >>>>from within emacs's elisp?
> >>>
> >>>
> >>>>Thanks,
> >>>>
> >>>>Bill
> >>>>
> >>>>
> >>>>
> >>>>_______________________________________________
> >>>>Siglinux mailing list
> >>>>[EMAIL PROTECTED]
> >>>>http://machito.utacm.org/mailman/listinfo/siglinux
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >
> >
> >
>
>
>
_______________________________________________
Siglinux mailing list
[EMAIL PROTECTED]
http://machito.utacm.org/mailman/listinfo/siglinux

Reply via email to