Page 1 sur 1

[RESOLVED] run remote commands

Publié : 22 mars 2018 - 13:24
par empbilly
Hello,

I searched and did not find a specific command to remotely run a command.

Is there anything for that?

I tried the following way. I need to run remotely, for example, the command "wapt-get generete-uuid".

I tried as follows, but gave error.

Code : Tout sélectionner

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():
    print('executing remote command')
    run(r'c:\windows\system32\cmd.exe /c wapt-get generete-uuid')

Re: run remote commands

Publié : 22 mars 2018 - 14:01
par sfonteneau
You can get inspired by this package :

https://wapt.lesfourmisduweb.org/detail ... 3_all.wapt

Re: run remote commands

Publié : 22 mars 2018 - 14:16
par empbilly
sfonteneau a écrit : 22 mars 2018 - 14:01 You can get inspired by this package :

https://wapt.lesfourmisduweb.org/detail ... 3_all.wapt
wow!! Thanks sfonteneau!!! Works like a charm!!

Re: run remote commands

Publié : 23 mars 2018 - 21:27
par empbilly
sfonteneau,

Regarding my example,

Code : Tout sélectionner

run(r'c:\windows\system32\cmd.exe /c wapt-get generete-uuid')
This would work via WAPT?

Re: run remote commands

Publié : 24 mars 2018 - 00:26
par htouvet
Theoritically,

Code : Tout sélectionner

run(r'wapt-get generete-uuid')
would be enough as the run command starts a sub shell (cmd) by default.

generate-uuid could eventually work but a lot of other "wapt-get" would not work properly because only one wapt process must be running at a time (and the waptservice is a wapt process).

And if you can do what you need directly using python, you have more control to handle the exceptions (try: except: try finally: etc..) as you would have with a cmd shell

Re: run remote commands

Publié : 26 mars 2018 - 14:41
par empbilly
htouvet a écrit : 24 mars 2018 - 00:26 Theoritically,

Code : Tout sélectionner

run(r'wapt-get generete-uuid')
would be enough as the run command starts a sub shell (cmd) by default.

generate-uuid could eventually work but a lot of other "wapt-get" would not work properly because only one wapt process must be running at a time (and the waptservice is a wapt process).

And if you can do what you need directly using python, you have more control to handle the exceptions (try: except: try finally: etc..) as you would have with a cmd shell
hello htouvet,

Using python directly does it need the target machine to have python installed or wapt client take care of it? Need execution with administrative rights?

Re: run remote commands

Publié : 26 mars 2018 - 19:35
par dcardon
Hi empbilly,
empbilly a écrit : 26 mars 2018 - 14:41 Using python directly does it need the target machine to have python installed or wapt client take care of it? Need execution with administrative rights?
wapt come with its own python 2.7 interpreter. It is located in the base directory of the wapt installation, normally c:\program files (x86)\wapt\waptpython.exe . You can add your own python interpreter if you really need it.

Cheers,

Denis

Re: run remote commands

Publié : 26 mars 2018 - 21:30
par empbilly
The answer is in the topic of the link below.

viewtopic.php?f=10&t=1083