tramp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tramp (2.2.3-pre); [Feature Request] Use winexe to execute shell com


From: Dave Abrahams
Subject: Re: tramp (2.2.3-pre); [Feature Request] Use winexe to execute shell commands on windows
Date: Mon, 08 Aug 2011 10:27:22 -0400
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.3 (darwin)

on Mon Aug 08 2011, Michael Albinus <michael.albinus-AT-gmx.de> wrote:

> Dave Abrahams <address@hidden> writes:
>
>>> Oops. Don't know, whether I could exploit my wife's laptop this way ...
>>> Let me check.
>>>
>>> An alternative would be that I write something for tramp-smb.el blindly,
>>> and let you test. Will be hard to debug, 'tho.
>>>
>>> Or do you see a chance I could access a windows machine, through VPN,
>>> which runs the server part? Could be even in a virtual machine.
>>
>> We can set it up, but it will take some effort on our part.  It'd be
>> much easier overall if you can do this on your wife's machine.  Just let
>> us know.
>
> OK, let's start with option 2. If it fails, we'll try option 1; option 3
> will be the last resort.

Great, thanks.

To give you a sense of what's possible, here's a python script I
am using to run commands on a windows VM:

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env python
from subprocess import Popen, list2cmdline, PIPE, call
import sys

p = Popen([
  'winexe', '-U', 'win7ult32/dave%mypassword', '//Win7ult32', 
  ' && '.join([
                'cmd.exe /q /c set GIT_PAGER=',
                r'net use s: \\vboxsvr\src /persistent:no > nul',
                's:',
                list2cmdline(sys.argv[1:])])
                +' || exit %errorlevel%'
  ])

try:
    retcode = p.wait()
except:
    p.kill()
    raise

exit(retcode)
--8<---------------cut here---------------end--------------->8---

This has been working very reliably for me [note:
subprocess.list2cmdline does *windows* cmd quoting, even when run on
Posix].  I can type, e.g.,

--8<---------------cut here---------------start------------->8---
winx command1 \&\& command2
--8<---------------cut here---------------end--------------->8---

into my posix command shell and it will run those commands on the
windows machine almost instantly.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]