emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Matthias Teege <matthias-omd@mteege.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Passing a table to org-babel shell script
Date: Sat, 06 Feb 2010 11:33:16 -0700	[thread overview]
Message-ID: <87wryqfc3b.fsf@gmail.com> (raw)
In-Reply-To: 20100124094734.GA10344@cab

Hi Matthias,

Sorry about the slow reply.  This is a good question, I have comments
in-line below.

Matthias Teege <matthias-omd@mteege.de> writes:

[...]

> But if I use more then one column, If got an error:
>
> #+tblname: sec
> | Hello | World |
>
> #+begin_src sh :var table=sec
> cat <<EOF
> $table
> EOF
> #+end_src
>
> #+results:
> | sh: Zeile 1: World]]: command not found. |
>
> It looks like, then Shell interprets the seperator "|" as pipe.
>
> How do I use a multicolumn table as input for a shell script?
>

This is a good question, clearly the current approach of dumping it in
as a string isn't working, however I'm not sure what a good alternative
would be.  Some ideas that come to mind are...

1) allowing the user to specify a separator with a header argument as
   follows
   #+begin_src sh :var table=sec :separator ,
     cat <<EOF
     $table
     EOF
   #+end_src
   
   which would result in something like

   : "Hello, World"

2) writing the table to a tab or comma separated file and then
   replacing =$table= in the source block body with the path to the
   file name, s.t. something like
   
   #+begin_src sh :var table=data
     wc $table
   #+end_src

   would return reasonable results

I guess this would largely depend on what types of values you are
passing to the shell, and what your use-case is.

I'd be interested to hear other people's feedback here as the "right"
solution will be largely dependent on how people would actually be using
tables in shell scripts.

Thanks for bringing this up! -- Eric

  reply	other threads:[~2010-02-06 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-24  9:47 Passing a table to org-babel shell script Matthias Teege
2010-02-06 18:33 ` Eric Schulte [this message]
2010-02-07  9:01   ` Matthias Teege
2010-02-07 17:20     ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wryqfc3b.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=matthias-omd@mteege.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).