2

I have a situation where I often want to run the same set of shell commands on different servers. Such a series of commands can look like:

#+begin_src bash :dir /ssh:purple:~/repo/
git pull --quiet origin master
git show | head -n 1
#+end_src

#+begin_src bash :dir /ssh:purple|su:root@purple:/
diff /sbin/thing /home/rovanion/repo/thing
#+end_src

I then want to repeat the same set of commands for a different machine, in a different org-file. Instead of running, and sometimes forgetting to run, search and replace for the hostname (purple) I would like to do something along these lines:

#+property: host purple

#+begin_src bash :dir /ssh:$host:~/repo/
git pull --quiet origin master
git show | head -n 1
#+end_src

#+begin_src bash :dir /ssh:$host|su:root@$host:/
diff /sbin/thing /home/rovanion/repo/thing
#+end_src

Where the property host can be defined per buffer. Is this possible?

Since I want to use different :dir's for different parts of the command sequences just setting the header-argument :dir is not practical.

1 Answer 1

2

This answer will get ya there: https://emacs.stackexchange.com/a/50767/24007

But define a property and get its value with org-entry-get. Something like this might be what you're looking for:

#+PROPERTY: me michael

#+BEGIN_SRC shell :dir (format "/home/%s" (org-entry-get nil "me" t))
echo $PWD
#+END_SRC

#+RESULTS:
: /home/michael

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.