From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: org-babel : passing variables to sh/screen blocks ? Date: Tue, 23 Feb 2010 11:09:57 -0500 Message-ID: <87fx4s0w8a.fsf@stats.ox.ac.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjxKv-00007i-0T for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 11:10:13 -0500 Received: from [140.186.70.92] (port=53920 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjxKq-00006w-Cd for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 11:10:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NjxKp-0008PT-7a for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 11:10:08 -0500 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:63969) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NjxKo-0008P5-Vg for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 11:10:07 -0500 In-Reply-To: (Julien Fantin's message of "Tue, 23 Feb 2010 02:10:51 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Julien Fantin Cc: emacs-orgmode@gnu.org Julien Fantin writes: > I haven't been able to do so, is it possible ? > > I'm trying to make an org file that will take care of fetching and intsalling > all my required packages, and it would really help in making things more > streamlined, if shell blocks could source some variables from 'accessible' > places in the file... > > It would be even more convenient if I could use :PROPERTIES: drawers, but I > wasn't even able to do that in a language other than elisp, so I'm not holding > my breath here. > > Any help will be appreciated though ! Hi Julien, Yes, you can pass data from org tables to shell blocks just like for other languages, and you can also use property drawers to hold header arguments to be inherited by all blocks in the subtree. Here's a quick example that shows both. It also shows how to slice a single column out of an org table and pass that to the shell script. --8<---------------cut here---------------start------------->8--- * Data #+tblname: package-list-1 | packagename-1-1 | | packagename-1-2 | #+tblname: package-list-2 | packagename-2-1 | | packagename-2-2 | #+tblname: package-list-3 | Package which does X | packagename-3-1 | | package which does Y | packagename-3-2 | | package which does Z | packagename-3-3 | * Referring to tables in source blocks :PROPERTIES: :results: output :var: datafromproperty=package-list-1 :END: *** Tables with one column #+begin_src sh :var datafromheaderarg=package-list-2 for package in $datafromproperty ; do echo "Installing $package" done echo for package in $datafromheaderarg ; do echo "Installing $package" done #+end_src #+results: : Installing packagename-1-1 : Installing packagename-1-2 : : Installing packagename-2-1 : Installing packagename-2-2 *** Operating on one column of a table #+begin_src sh :results output :var packages=package-list-3[0:2,1] for package in $packages ; do echo "Installing $package" done #+end_src #+results: : Installing packagename-3-1 : Installing packagename-3-2 : Installing packagename-3-3 --8<---------------cut here---------------end--------------->8--- Actually, with yesterday's org, you will get quoted strings like this: Installing "packagename-1-1" That bug is fixed now so you'll need to pull the latest git version. Dan > > Regards, fellow org-moders. > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode