emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ista Zahn <istazahn@gmail.com>
To: David Bjergaard <david.b@duke.edu>
Cc: Brett Viren <bv@bnl.gov>,
	emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: Executing org shell blocks on remote machine over ssh
Date: Tue, 18 Nov 2014 13:31:48 -0500	[thread overview]
Message-ID: <CA+vqiLGY61ZfZ2XF8ZM7-Oap6B6cg_ZNMLNk-nNsOAy4Lqn8Ow@mail.gmail.com> (raw)
In-Reply-To: <87ioic8j1u.fsf@duke.edu>

On Tue, Nov 18, 2014 at 1:23 PM, David Bjergaard <david.b@duke.edu> wrote:
> Ista Zahn <istazahn@gmail.com> writes:
>
>> On Tue, Nov 18, 2014 at 10:43 AM, Brett Viren <bv@bnl.gov> wrote:
>>> David Bjergaard <david.b@duke.edu> writes:
>>>
>>>> I use org mode as a lab notebook.  I write org-src blocks to keep track
>>>> of tasks I do at the command line, and then I copy paste them into the
>>>> terminal.  I would really like to hit "C-c C-c" on the source block and
>>>> have it executed on the remote machine.  I know that you can specify
>>>> the remote machine according to [1], however the software I use requires
>>>> a fairly complicated setup to get going.
>>>
>>> Is it just complicated, or is it also prohibitively long-running?
>>>
>>> If just the former, you could maybe bundle the setup into some shell
>>> script and source it in each of your sh source blocks.  Eg:
>>>
>>> #+BEGIN_SRC sh :results output :dir /ssh:lycastus:/home/bviren
>>>   /bin/pwd
>>>   echo $HOSTNAME
>>>   ls -l foo.sh
>>>   echo "---"
>>>   cat foo.sh
>>>   echo "---"
>>>   source ./foo.sh
>>>   echo $FOO
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> : /home/bviren
>>> : lycastus
>>> : -rw-rw-r-- 1 bviren bviren 16 Nov 18 10:27 foo.sh
>>> : ---
>>> : export FOO=bar
>>> :
>>> : ---
>>> : bar
>>>
>>>
>>>
>>> If the setup is purely environmental, and it takes a long time to
>>> perform, maybe you could do the set up once and then cache the resulting
>>> environment using the output of "env".
>>
>> I guess I'm missing something (like why the OP want's to run a shell
>> in a separate window), but why not just
>>
>> #+BEGIN_SRC sh :results output :dir /ssh:lycastus:/home/bviren :session *shell*
>>   /bin/pwd
>>   echo $HOSTNAME
>>   ls -l foo.sh
>>   echo "---"
>>   cat foo.sh
>>   echo "---"
>>   source ./foo.sh
>>   echo $FOO
>> #+END_SRC
>>
>> ?
>>
>> Best,
>> Ista
>>>
>>>
>>> -Brett.
> Hi Ista, Brett,
>
> Thanks for the hints, I'll try these.
> Some clarification:
>>> If the setup is purely environmental, and it takes a long time to
>>> perform, maybe you could do the set up once and then cache the resulting
>>> environment using the output of "env".
> Unfortunately it takes a long time to set up, and its complicated (I
> have to initialize different versions of the software depending on
> which project I'm working on.) It can take up to 10 seconds to restore a
> saved environment, and it takes some setting up bootstrap the
> restoration command.
>> I guess I'm missing something (like why the OP want's to run a shell
>> in a separate window), but why not just
> I want the separate window because once the environment is set up, I
> also jump around a lot.

Emacs is great for jumping around a lot, another reason to run the
shell inside emacs instead of in a separate window.

I record the pieces of shell script that are
> important for reproducing results in the notebook.  The snippets are
> then recycled across many sessions, and different pieces are used at
> different times (some are even used with different pieces of software).
>
> What I would like is to log into the remote machine, set up the
> software, and then have a way to tell emacs to send the org-src block to
> the set up environment so that I can build up the parts I need at that
> moment.
>
> 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.

It really does sound to me like you're just looking for the :session argument.

Best,
Ista

 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).
>
> Cheers,
>
>     Dave

  reply	other threads:[~2014-11-18 18:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17 16:04 Executing org shell blocks on remote machine over ssh David Bjergaard
2014-11-17 22:50 ` Myles English
2014-11-18 15:55   ` Andreas Leha
2014-11-18 15:43 ` Brett Viren
2014-11-18 18:12   ` Ista Zahn
2014-11-18 18:23     ` David Bjergaard
2014-11-18 18:31       ` Ista Zahn [this message]
2014-11-18 19:03       ` Brett Viren
2014-11-18 19:52       ` Subhan Michael Tindall
2014-11-18 20:58     ` Brady Trainor
2014-11-18 22:01       ` Andreas Leha

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=CA+vqiLGY61ZfZ2XF8ZM7-Oap6B6cg_ZNMLNk-nNsOAy4Lqn8Ow@mail.gmail.com \
    --to=istazahn@gmail.com \
    --cc=bv@bnl.gov \
    --cc=david.b@duke.edu \
    --cc=emacs-orgmode@gnu.org \
    /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).