emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: George Jones <eludom@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: remote execution in heterogeneous environment
Date: Thu, 20 Dec 2012 14:16:24 +0100	[thread overview]
Message-ID: <87hang279z.fsf@gmx.de> (raw)
In-Reply-To: <87623zaj4j.fsf@gmx.de> (Michael Albinus's message of "Tue, 18 Dec 2012 08:56:28 +0100")

Michael Albinus <michael.albinus@gmx.de> writes:

Hi,

> Looks, like nobody did take the ball :-(
>
> Maybe I'll check it again over XMas days, and maybe I can propose a
> concrete patch then.

The following patch I've committed to Emacs' trunk, it fixes the problem
as far as I could test. Maybe somebody from the org maintainers could
merge it into the org repository.

--8<---------------cut here---------------start------------->8---
~/src/emacs/lisp/org> bzr diff >123
=== modified file 'lisp/org/ChangeLog'
--- lisp/org/ChangeLog	2012-12-13 05:29:15 +0000
+++ lisp/org/ChangeLog	2012-12-20 13:09:40 +0000
@@ -1,3 +1,12 @@
+2012-12-20  Michael Albinus  <michael.albinus@gmx.de>
+
+	* ob.el (org-babel-temp-file): Fix setting of
+	`temporary-file-directory' on remote hosts.
+
+	* ob-eval.el (org-babel-shell-command-on-region): Use
+	`process-file' instead of `call-process-region'.  The latter one
+	does not work on remote hosts.
+
 2012-12-13  Bastien Guerry  <bzg@gnu.org>

 	* org-latex.el (org-export-latex-links): Escape raw path when

=== modified file 'lisp/org/ob-eval.el'
--- lisp/org/ob-eval.el	2012-09-30 15:14:59 +0000
+++ lisp/org/ob-eval.el	2012-12-20 13:06:27 +0000
@@ -134,14 +134,13 @@
 		       current-prefix-arg
 		       shell-command-default-error-buffer
 		       t)))
-  (let ((error-file
-	 (if error-buffer
-	     (make-temp-file
-	      (expand-file-name "scor"
-                                (if (featurep 'xemacs)
-                                    (temp-directory)
-                                  temporary-file-directory)))
-	   nil))
+  (let ((input-file (org-babel-temp-file "input-"))
+	(error-file (if error-buffer (org-babel-temp-file "scor-") nil))
+	(shell-file-name
+	 (if (file-executable-p
+	      (concat (file-remote-p default-directory) shell-file-name))
+	     shell-file-name
+	   "/bin/sh"))
 	exit-status)
     (if (or replace
 	    (and output-buffer
@@ -151,12 +150,14 @@
 	  ;; Don't muck with mark unless REPLACE says we should.
 	  (goto-char start)
 	  (and replace (push-mark (point) 'nomsg))
+	  (write-region start end input-file)
+	  (delete-region start end)
 	  (setq exit-status
-		(call-process-region start end shell-file-name t
-				     (if error-file
-					 (list output-buffer error-file)
-				       t)
-				     nil shell-command-switch command))
+		(process-file shell-file-name input-file
+			      (if error-file
+				  (list output-buffer error-file)
+				t)
+			      nil shell-command-switch command))
 	  ;; It is rude to delete a buffer which the command is not using.
 	  ;; (let ((shell-buffer (get-buffer "*Shell Command Output*")))
 	  ;;   (and shell-buffer (not (eq shell-buffer (current-buffer)))
@@ -175,14 +176,14 @@
 		(progn (setq buffer-read-only nil)
 		       (delete-region (max start end) (point-max))
 		       (delete-region (point-min) (min start end))
+		       (write-region (point-min) (point-max) input-file)
+		       (delete-region (point-min) (point-max))
 		       (setq exit-status
-			     (call-process-region (point-min) (point-max)
-						  shell-file-name t
-						  (if error-file
-						      (list t error-file)
-						    t)
-						  nil shell-command-switch
-						  command)))
+			     (process-file shell-file-name input-file
+					   (if error-file
+					       (list t error-file)
+					     t)
+					   nil shell-command-switch command)))
 	      ;; Clear the output buffer, then run the command with
 	      ;; output there.
 	      (let ((directory default-directory))
@@ -192,11 +193,11 @@
 		      (setq default-directory directory))
 		  (erase-buffer)))
 	      (setq exit-status
-		    (call-process-region start end shell-file-name nil
-					 (if error-file
-					     (list buffer error-file)
-					   buffer)
-					 nil shell-command-switch command)))
+		    (process-file shell-file-name nil
+				  (if error-file
+				      (list buffer error-file)
+				    buffer)
+				  nil shell-command-switch command)))
 	  ;; Report the output.
 	  (with-current-buffer buffer
 	    (setq mode-line-process
@@ -230,6 +231,9 @@
 	    ;; (kill-buffer buffer)
 	    ))))

+    (when (and input-file (file-exists-p input-file))
+      (delete-file input-file))
+
     (when (and error-file (file-exists-p error-file))
       (if (< 0 (nth 7 (file-attributes error-file)))
 	  (with-current-buffer (get-buffer-create error-buffer)

=== modified file 'lisp/org/ob.el'
--- lisp/org/ob.el	2012-10-26 14:42:05 +0000
+++ lisp/org/ob.el	2012-12-20 13:05:00 +0000
@@ -2547,18 +2547,14 @@
 Passes PREFIX and SUFFIX directly to `make-temp-file' with the
 value of `temporary-file-directory' temporarily set to the value
 of `org-babel-temporary-directory'."
-  (if (file-remote-p default-directory)
-      (make-temp-file
-       (concat (file-remote-p default-directory)
-	       (expand-file-name
-		prefix temporary-file-directory)
-	       nil suffix))
-    (let ((temporary-file-directory
+  (let ((temporary-file-directory
+	 (if (file-remote-p default-directory)
+	     (concat (file-remote-p default-directory) "/tmp")
 	   (or (and (boundp 'org-babel-temporary-directory)
 		    (file-exists-p org-babel-temporary-directory)
 		    org-babel-temporary-directory)
-	       temporary-file-directory)))
-      (make-temp-file prefix nil suffix))))
+	       temporary-file-directory))))
+      (make-temp-file prefix nil suffix)))

 (defun org-babel-remove-temporary-directory ()
   "Remove `org-babel-temporary-directory' on Emacs shutdown."
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.

  reply	other threads:[~2012-12-20 16:35 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6D36E0F9-01D1-4F95-9FAA-B2B2CA10E57E@gmail.com>
2012-12-18  7:56 ` remote execution in heterogeneous environment Michael Albinus
2012-12-20 13:16   ` Michael Albinus [this message]
2012-12-20 16:39     ` Bastien
2012-12-20 16:59       ` Achim Gratz
2012-12-20 17:09         ` Nick Dokos
2012-12-20 17:15           ` Bastien
2012-12-20 17:12         ` Bastien
2012-12-20 20:25           ` Achim Gratz
2012-12-20 17:23         ` Michael Albinus
2012-12-20 17:30           ` Bastien
2012-12-21  8:24             ` Michael Albinus
2012-12-21  8:51               ` Bastien
2012-12-21 17:32               ` Nick Dokos
2012-12-21  1:21       ` George Jones
2012-12-21  8:27         ` Michael Albinus
2012-12-22 13:32           ` George
2012-12-22 13:36           ` George
2012-12-22 13:48             ` Michael Albinus
     [not found]               ` <CAOhM7yVOvrL0F8v1hAnxb4z0Mw0kTf6L6_uZk5o7T3W08geUeg@mail.gmail.com>
     [not found]                 ` <CAOhM7yXmD3OEhBt66Ts9YG+8s9LKhkw0-BT0grh734fH07p2pw@mail.gmail.com>
2012-12-23 14:10                   ` Michael Albinus
2012-12-23 15:14                     ` Bastien
2012-12-23 16:09                       ` Michael Albinus
2012-12-23 16:47                         ` Bastien
2012-12-23 17:53                           ` George Jones
2012-12-23 19:54                             ` Bastien
2012-12-23 21:37                               ` George Jones
2012-12-24 13:38                                 ` Michael Albinus
2013-01-07 16:44     ` [BUG] " Achim Gratz
2013-01-08  8:36       ` Michael Albinus
2013-01-08 17:30         ` Achim Gratz
2013-01-08 18:02           ` Eric Schulte
2013-01-08 21:11           ` Michael Albinus
2013-01-09  7:31         ` Achim Gratz
2013-01-09  8:16           ` Michael Albinus
2013-01-09 11:49             ` Bastien
2013-01-09 13:05               ` Michael Albinus
2013-01-09 13:11                 ` Bastien
2012-11-29 16:48 Neil Best
2012-11-29 17:05 ` Nick Dokos
2012-11-29 17:16 ` Nick Dokos
2012-11-29 21:48   ` Neil Best
     [not found]   ` <CANVU8H2wkXN90W+C24t75TDVEctGLqYOYi-H7e86_a2OkFFO8Q@mail.gmail.com>
     [not found]     ` <11047.1354217134@alphaville>
2012-11-29 22:07       ` Neil Best
2012-11-30  7:37 ` Michael Albinus
2012-11-30 15:33   ` Nick Dokos
2012-11-30 17:12     ` Michael Albinus
2012-11-30 18:24       ` Nick Dokos
2012-11-30 19:13         ` Michael Albinus
2012-11-30 18:02   ` Neil Best
2012-11-30 19:22     ` Michael Albinus
2012-11-30 20:13       ` Neil Best
2012-12-01  9:49         ` Michael Albinus

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=87hang279z.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=eludom@gmail.com \
    --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).