From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Scripting with org-mode Date: Mon, 30 Nov 2015 14:15:38 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3TvO-00062t-73 for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 14:15:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3TvK-0005b0-Vi for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 14:15:46 -0500 Received: from mail-qg0-x22c.google.com ([2607:f8b0:400d:c04::22c]:34253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3TvK-0005ab-PG for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 14:15:42 -0500 Received: by qgeb1 with SMTP id b1so127306888qge.1 for ; Mon, 30 Nov 2015 11:15:42 -0800 (PST) In-reply-to: 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: Shakthi Kannan Cc: emacs-orgmode@gnu.org I think one of these will do what you want: ** Rerun all src blocks #+BEGIN_SRC emacs-lisp (defun run-blocks () (interactive) (save-excursion (org-element-map (org-element-parse-buffer) 'src-block (lambda (src-block) (goto-char (org-element-property :begin src-block)) (org-babel-execute-src-block))))) #+END_SRC #+RESULTS: : run-blocks #+BEGIN_SRC emacs-lisp (defun run-blocks-2 () (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "^#\\+BEGIN_SRC" nil t) (org-babel-execute-src-block)))) #+END_SRC #+RESULTS: Shakthi Kannan writes: > Hi, > > Is there a way to execute all the org-mode code blocks in a file, and > send the output to stdout? > > For example, I have the following org file: > > === BEGIN === > > * Greeting > > #+BEGIN_SRC sh :results output > echo "Hello $USER! Today is `date`" > #+END_SRC > > * Current directory > > #+BEGIN_SRC sh :results output > pwd > #+END_SRC > > === END === > > I could go to each code block, and type C-c C-c to produce an output. > But, I just want to be able to execute the entire file, and produce > one single output. > > Is this possible? > > SK -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu