From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: remote plot with local output? Date: Mon, 14 Sep 2015 13:42:55 -0700 Message-ID: References: <87bnd5gho8.fsf@gentoo.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbaaf-0004lg-P7 for emacs-orgmode@gnu.org; Mon, 14 Sep 2015 16:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbaaa-0002vl-Gl for emacs-orgmode@gnu.org; Mon, 14 Sep 2015 16:43:05 -0400 Received: from iport-bcv1-out.ucsd.edu ([132.239.0.119]:12090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbaaa-0002v9-7w for emacs-orgmode@gnu.org; Mon, 14 Sep 2015 16:43:00 -0400 In-Reply-To: <87bnd5gho8.fsf@gentoo.org> 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: Benda Xu Cc: emacs-orgmode@gnu.org On Tue, 15 Sep 2015, Benda Xu wrote: > Dear All, > > I am looking for a way to configure org-babel so that a program runs > remotely and outputs locally. An example is > > #+NAME: line > | 1 | > | 2 | > | 3 | > > #+BEGIN_SRC python :results file :var dt=line :dir /ipmuap02:/tmp > from matplotlib import pylab as plt > plt.plot(dt) > plt.savefig("line.png") > return "line.png" > #+END_SRC > > #+RESULTS: > [[file:/scp:ipmuap02:/tmp/line.png]] > > I would like to embed this figure into my note. The example above need > to fetch the figure from the remote host on each exportation, which is > very sensitive to the network environment. > > I cannot make the plot locally, because (unlike the over-simplified > example) some potentially big data are only available remotely. > > My solution is to cache the result (:cache yes), execute the code block, > copy the output file to localhost, update the #+RESULTS link to the > local one, manually. Now I am facing many such tasks and feel like > automating that. > > > What is the recommended way for copying the file output from an remote > execution code block back to localhost? > Look at the :post header arg (info "(org) post") You write a src block that extracts the remote file name from *this*, creates a local file name from it, copies the remote file to the local host, then substitutes the local file name in *this* and uses it as the return value. Use the name of that src block as the argument to :post HTH, Chuck