From mboxrd@z Thu Jan 1 00:00:00 1970 From: edgar@openmail.cc Subject: How to call nested bash and gnuplot with babel? Date: Fri, 25 Aug 2017 03:26:58 +0000 Message-ID: <8df2f105af6682485733fe21a879feb4@openmail.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlH7k-0004nt-8b for emacs-orgmode@gnu.org; Fri, 25 Aug 2017 12:06:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlH7e-0003w0-DP for emacs-orgmode@gnu.org; Fri, 25 Aug 2017 12:06:18 -0400 Received: from onethreetwo.vfemail.net ([199.16.11.132]:52761 helo=vfemail.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dlH7e-0003ud-5p for emacs-orgmode@gnu.org; Fri, 25 Aug 2017 12:06:14 -0400 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" To: emacs-orgmode@gnu.org Hello, I am trying to run a "nested" babel code with bash and gnuplot. * Configuration I did the test like this #+BEGIN_SRC bash emacs -Q #+END_SRC #+BEGIN_SRC emacs-lisp (require 'package) (package-initialize) (require 'org) ;; Org mode version 9.0.9 (org-babel-do-load-languages ; babel, for executing 'org-babel-load-languages ; code in org-mode. '((shell . t) (python . t) (emacs-lisp . t) (org . t) (gnuplot . t))) #+END_SRC * Original code #+NAME: bash-tjp-displ-stress #+HEADER: :var file1="file1.csv" #+HEADER: :var col1="3" #+HEADER: :var file2="file2.csv" #+HEADER: :var col2="7" #+HEADER: :dir "Data" #+BEGIN_SRC bash :results value :exports code paste "$file1" "$file2" | awk -F',' '/^[^#]/{print $'$col1' $'$col2'}' #+END_SRC #+NAME: gplt-tjp-febio-results #+CAPTION: Gnuplot to plot #+HEADER: :var data=bash-tjp-displ-stress #+BEGIN_SRC gnuplot :results graphics :file /tmp/orig-out.png set xlabel 'var1' set ylabel 'var2' plot data u ($1 + 1):2 with lp notitle #+END_SRC ** Alternative 1: ~:file~ after the function The result of this gives me the original output file #+CALL: gplt-tjp-febio-results() :file /tmp/test.png #+RESULTS: [[file:/tmp/orig-out.png]] ** Alternative 2: ~:file~ as a prefix to the function The result of this gives me the original output file #+CALL: gplt-tjp-febio-results[:file /tmp/test.png]() #+RESULTS: [[file:/tmp/orig-out.png]] * Modified code If I do this, I get the desired output file (add variable ~outfile~ and ~:results none~) #+NAME: gplt-tjp-febio-results-new #+CAPTION: Gnuplot to plot #+HEADER: :var data=bash-tjp-displ-stress #+HEADER: :var outfile="/tmp/test.png" #+BEGIN_SRC gnuplot :results graphics set output outfile set xlabel 'var1' set ylabel 'var2' plot data u ($1 + 1):2 with lp notitle #+END_SRC #+CALL: gplt-tjp-febio-results-new[:results none](outfile="/tmp/new_out.png") I type this manually: [[/tmp/new_out.png]] * What I expected To call #+BEGIN_EXAMPLE ,#+CALL: gplt-tjp-febio-results() :file /tmp/new_out.png #+END_EXAMPLE and get #+BEGIN_EXAMPLE ,#+RESULTS: [[file:/tmp/orig-out.png]] #+END_EXAMPLE How do I achieve this? * Thanks Thank you! :D ------------------------------------------------- ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands! $24.95 ONETIME Lifetime accounts with Privacy Features! 15GB disk! No bandwidth quotas! Commercial and Bulk Mail Options!