1

All of my python scripts run in my anaconda environment on Mac OS. It would be so convenient to be able to incorporate a couple of arcpy functions. Those only can run in Windows, which I emulate with vmware fusion.

I could move the whole project to Windows (a nuisance). I could write the equivalent of those arcpy functions in gdal/ogr for python (learning curve).

But, before I do one of those, I'd like to check if there is maybe some way to reach across the divide and have my Mac-based script run a few windows things over in the vm without my hands-on supervision (copying and pasting inputs and outputs back and forth, e.g.)?

pattivacek
  • 5,617
  • 5
  • 48
  • 62
J Kelly
  • 480
  • 1
  • 5
  • 15

1 Answers1

2

Yes,

You could probably do it via pywinrm https://github.com/diyan/pywinrm

import winrm

s = winrm.Session('windows-host.example.com', auth=('john.smith', 'secret'))
r = s.run_cmd('ipconfig', ['/all'])
>>> r.status_code
0
>>> r.std_out
Windows IP Configuration

   Host Name . . . . . . . . . . . . : WINDOWS-HOST
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
...
>>> r.std_err
Kelvin
  • 1,357
  • 2
  • 11
  • 22
  • I don't mind, but why was the answer downvoted? I'd like to be able to improve it. – Kelvin Feb 15 '17 at 14:44
  • I think it's a good answer bc that package claims to also run batch commands, which would also be very helpful. I will give it a try, thanks. – J Kelly Feb 15 '17 at 15:36