From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] Parse another code block's output then use captured data in another code block Date: Fri, 07 Mar 2014 08:35:30 -0700 Message-ID: <87mwh2qawt.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLwq9-0002vW-5k for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 10:37:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLwq4-00043e-Ey for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 10:37:37 -0500 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]:44309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLwq4-00043L-4Y for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 10:37:32 -0500 Received: by mail-pa0-f54.google.com with SMTP id lf10so4318640pab.13 for ; Fri, 07 Mar 2014 07:37:31 -0800 (PST) In-Reply-To: (Rehan Iftikhar's message of "Fri, 7 Mar 2014 07:23:43 -0800") 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: Rehan Iftikhar Cc: emacs-orgmode@gnu.org Would something like the following work? Rehan Iftikhar writes: > Hello > > I have a .org file where I am using sh code blocks to interact with a REST > API via curl. #+name: downloader #+begin_src sh curl something #+end_src > My first call is to authenticate with the REST API which returns a > token in the HTTP response. I would like to parse that HTTP response > (ie. with elisp via a subsequent code block) #+name: parser #+begin_src emacs-lisp :var input=foo ;; do parsing #+end_src > and use the token in subsequent sh code blocks. > #+begin_src sh :var data=parser(downloader) echo "$data" #+end_src > > Right now I am doing this via a manual step where I step where I run > the first sh code block, set a :var PROPERTY, and then run the rest of > the sh code blocks. I would like to automate it if possible. > It is possible to chain code blocks in variable lines as shown, see the manual pages on the :var and potentially also the :post header arguments. Also, the following has multiple examples demonstrating this sort of usage. http://www.jstatsoft.org/v46/i03/ Best, > > Thanks, > -Rehan -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D