all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mathias Dahl <brakjoller@hotmail.com>
Subject: Re: Win32 - how do I execute a shell command?
Date: 30 Jul 2004 09:15:11 +0200	[thread overview]
Message-ID: <uisc6c6f4.fsf@hotmail.com> (raw)
In-Reply-To: k6wmms1a.fsf@yahoo.co.uk

Paul Moore <pf_moore@yahoo.co.uk> writes:

> I have a Python script I want to execute and obtaing the stdout. In
> XEmacs, I can do so simply using
> 
>     (shell-command-to-string (expand-file-name "~/fortune.py"))
> 
> This doesn't work in Gnu Emacs, basically because expand-file-name
> returns filenames with *forward* slashes, which the shell doesn't
> like.
> 
> OK, I could do a global replace of / with \, but that seems like a
> hack. Is there a "expand file name in Win32 native format" (ie, with
> backslashes) function?

I have found no such function so I use this:

 (defun slash-to-backslash (text)
   (substitute ?\\ ?/ text))

Also, as Jason tells you, you should either use cmd.exe's
start command, if the .py files is associated with the
correct program, or explicitly start it with the correct
interpreter.

Something like this should work (not tested);

(shell-command-to-string 
  (concat "python " (slash-to-backslash (expand-file-name "~/fortune.py"))))

/Mathias

      parent reply	other threads:[~2004-07-30  7:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-29 21:18 Win32 - how do I execute a shell command? Paul Moore
2004-07-29 21:36 ` Jason Rumney
2004-07-30 19:43   ` Paul Moore
2004-07-30  7:15 ` Mathias Dahl [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uisc6c6f4.fsf@hotmail.com \
    --to=brakjoller@hotmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.