From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Batch mode evaluation of source code? Date: Fri, 17 Jun 2011 14:47:00 -0700 Message-ID: <8762o4ruzv.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:41284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXgsd-0004y8-0L for emacs-orgmode@gnu.org; Fri, 17 Jun 2011 17:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QXgsb-0002eo-Jn for emacs-orgmode@gnu.org; Fri, 17 Jun 2011 17:47:06 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:62150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXgsb-0002eZ-C2 for emacs-orgmode@gnu.org; Fri, 17 Jun 2011 17:47:05 -0400 Received: by pvc12 with SMTP id 12so2747890pvc.0 for ; Fri, 17 Jun 2011 14:47:03 -0700 (PDT) In-Reply-To: (Herbert Sitz's message of "Fri, 17 Jun 2011 21:14:25 +0000 (UTC)") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Herbert Sitz Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Herb, The following org-mode file and minimal elisp file can be used to print the results of evaluating a code block from a batch Emacs session (note this is using Emacs24, so Org-mode/Babel do not need to be explicitly loaded). I used the following command line : emacs --batch -l run-code.el 2> /dev/null And the following two files. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=run-code.el Content-Transfer-Encoding: quoted-printable (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) (let ((org-confirm-babel-evaluate nil)) (progn (find-file "short-code.org") (org-babel-next-src-block) (print (org-babel-execute-src-block)))) --=-=-= Content-Type: text/x-org Content-Disposition: attachment; filename=short-code.org #+Title: short code buffer #+begin_src python :results output print "hello" 2 print "bye" #+end_src #+results: : hello : bye --=-=-= Content-Type: text/plain Cheers -- Eric Herbert Sitz writes: > The Org manual gives an example of a batch mode --eval that runs code to tangle > code from Org files. I assume there's also a way to simply run a source code > block and get its output in the terminal but I can't see how to do it. > > To give a concrete example, the Org manual uses this Python source block as > example illustrating the difference between :session and non-session results > output. How would I evaluate it from the command line and get the results > output back in the terminal?: > > ------------------------- > #+begin_src python :results output > print "hello" > 2 > print "bye" > #+end_src > ------------------------ > > -- Herb > > > -- Eric Schulte http://cs.unm.edu/~eschulte/ --=-=-=--