emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel : passing variables to sh/screen blocks ?
@ 2010-02-23  1:10 Julien Fantin
  2010-02-23 16:09 ` Dan Davison
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Fantin @ 2010-02-23  1:10 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 536 bytes --]

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 !

Regards, fellow org-moders.

[-- Attachment #1.2: Type: text/html, Size: 665 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: org-babel : passing variables to sh/screen blocks ?
  2010-02-23  1:10 org-babel : passing variables to sh/screen blocks ? Julien Fantin
@ 2010-02-23 16:09 ` Dan Davison
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Davison @ 2010-02-23 16:09 UTC (permalink / raw)
  To: Julien Fantin; +Cc: emacs-orgmode

Julien Fantin <julien.fantin@gmail.com> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-23 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23  1:10 org-babel : passing variables to sh/screen blocks ? Julien Fantin
2010-02-23 16:09 ` Dan Davison

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).