From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brett Viren Subject: Re: Executing org shell blocks on remote machine over ssh Date: Tue, 18 Nov 2014 14:03:19 -0500 Message-ID: References: <874mtxx18q.fsf@duke.edu> <87ioic8j1u.fsf@duke.edu> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqo46-0000Cl-Oc for emacs-orgmode@gnu.org; Tue, 18 Nov 2014 14:03:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xqo40-0008PK-Jz for emacs-orgmode@gnu.org; Tue, 18 Nov 2014 14:03:50 -0500 Received: from smtpgw.bnl.gov ([2620:10a:0:3::30]:50952 helo=iron4.sec.bnl.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xqo40-0008OO-5e for emacs-orgmode@gnu.org; Tue, 18 Nov 2014 14:03:44 -0500 In-Reply-To: <87ioic8j1u.fsf@duke.edu> (David Bjergaard's message of "Tue, 18 Nov 2014 13:23:09 -0500") 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: David Bjergaard Cc: emacs-orgmode Mailinglist --=-=-= Content-Type: text/plain David Bjergaard writes: > I know this is working "against the grain" of the literate programming > paradigm where the document and the source code are coupled, and > tangling the document produces a program that can be executed. I'm just > wondering if its possible. If not that's fine. Really I'm just trying > to save myself a copy-paste (and the associated issues with it getting > recorded in my .bash_history). I usually come at it from the "reproducible research" angle which maybe is more relaxed than literate programming. In any case, I find it hard to capture all the info needed to reproduce something and so I settle for capturing as much as easily achievable - that is when I try at all as capturing it in an RR org doc greatly increases the time I need to do something. Many of the software stacks I use also take significant time to configure the end-user environment. 10 seconds is not unheard of and it can be minutes if the stack lives on slow network disk. I think the approach I suggested of caching the environment should work for you. Unfortunately, I do not know of a trivial, general way to do this. The "env" program comes close but does not spit out a format that is immediately consumable by the shell. In particular, spaces in variable values confound it. It also lacks the "export" keyword. And, in any case is only close to sh syntax. Any exported functions also have to be handled properly In your shoes, I'd probably write a small Python script that dumps the "os.environ" dictionary holding the environment of the caller into a form suitable for consumption by your shell. You can call this dumper in a shell code block at the top of your org file and source the result as the first line in each subsequent shell code block. A starting point would be something like the following, but this does not properly handle and sh functions defined. #!/usr/bin/env python import os for k,v in os.environ.items(): print 'export %s="%s"' % (k,v) Good luck! -Brett. --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlRrl/cACgkQEixH2Z0dKCz51gCgk6RiIJgV6Sf2ikNqdJCqF8pW ODcAoJhqcX3qb+FVifpuogHdynEZ/r9x =wQle -----END PGP SIGNATURE----- --=-=-=--