Contactez nous

[RESOLVED] run remote commands

Share here your tips or issues concerning WAPT Console or WAPT Agent / Venez ici partager vos problèmes et astuces concernants la console et l'agent WAPT
Règles du forum

* Questions can be asked in English or in French. If the thread is started in English, stick to English, if it is started in French, stick to French.
* Vous pouvez poser vos questions en Français ou en Anglais. Si un sujet est commencé en français, merci de répondre en français. Si un sujet est commencé en anglais, merci de répondre en anglais.

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')
You can get inspired by this package :

https://wapt.lesfourmisduweb.org/detail ... 3_all.wapt
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!!
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?
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
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?
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
The answer is in the topic of the link below.

viewtopic.php?f=10&t=1083