From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Scripting with org-mode Date: Mon, 30 Nov 2015 15:22:04 -0500 Message-ID: <87fuzngrv7.fsf@alphaville.usersys.redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Uxk-00053z-IC for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 15:22:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Uxh-0006zT-ER for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 15:22:16 -0500 Received: from plane.gmane.org ([80.91.229.3]:37061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Uxh-0006zL-86 for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 15:22:13 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a3Uxf-0007YN-Ns for emacs-orgmode@gnu.org; Mon, 30 Nov 2015 21:22:11 +0100 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Nov 2015 21:22:11 +0100 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 30 Nov 2015 21:22:11 +0100 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: emacs-orgmode@gnu.org John Kitchin writes: > 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? >> IIUC, org-babel-execute-buffer is exactly what the OP needs. -- Nick