[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
Règles du forum communautaire
* English support on www.reddit.com/r/wapt
* Le support communautaire en français se fait sur ce forum
* Merci de préfixer le titre du topic par [RESOLU] s'il est résolu.
* Merci de ne pas modifier un topic qui est taggé [RESOLU]. Ouvrez un nouveau topic en référençant l'ancien
* Préciser version de WAPT installée, version complète ET numéro de build (2.2.1.11957 / 2.2.2.12337 / etc.) AINSI QUE l'édition Enterprise / Discovery
* Les versions 1.8.2 et antérieures ne sont plus maintenues. Les seules questions acceptées vis à vis de la version 1.8.2 sont liés à la mise à jour vers une version supportée (2.1, 2.2, etc.)
* Préciser OS du serveur (Linux / Windows) et version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019)
* Préciser OS de la machine d'administration/création des paquets et de la machine avec l'agent qui pose problème le cas échéant (Windows 7 / 10 / 11 / Debian 11 / etc.)
* Eviter de poser plusieurs questions lors de l'ouverture de topic, sinon il risque d'être ignorer. Si plusieurs sujet, ouvrir plusieurs topic, et de préférence les uns après les autres et pas tous en même temps (ie ne pas spammer le forum).
* Inclure directement les morceaux de code, les captures d'écran et autres images directement dans le post. Les liens vers les pastebin, les bitly et autres sites tierces seront systématiquement supprimés.
* Comme tout forum communautaire, le support est fait bénévolement par les membres. Si vous avez besoin d'un support commercial, vous pouvez contacter le service commercial Tranquil IT au 02.40.97.57.55
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

22 mars 2018 - 13:24

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')
Dernière modification par empbilly le 26 mars 2018 - 21:30, modifié 3 fois.
Avatar de l’utilisateur
sfonteneau
Expert WAPT
Messages : 1783
Inscription : 10 juil. 2014 - 23:52
Contact :

22 mars 2018 - 14:01

You can get inspired by this package :

https://wapt.lesfourmisduweb.org/detail ... 3_all.wapt
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

22 mars 2018 - 14:16

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!!
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

23 mars 2018 - 21:27

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?
Avatar de l’utilisateur
htouvet
Expert WAPT
Messages : 402
Inscription : 16 mars 2015 - 10:48
Contact :

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
Tranquil IT
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

26 mars 2018 - 14:41

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?
Avatar de l’utilisateur
dcardon
Expert WAPT
Messages : 1373
Inscription : 18 juin 2014 - 09:58
Localisation : Saint Sébastien sur Loire
Contact :

26 mars 2018 - 19:35

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
Denis Cardon - Tranquil IT
Communiquez autour de vous sur WAPT! Envoyez nous vos url de blog et d'articles dans la catégorie votre avis du forum, nous les mettrons en avant sur le site WAPT
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

26 mars 2018 - 21:30

The answer is in the topic of the link below.

viewtopic.php?f=10&t=1083
Verrouillé