[RESOLVED] run remote commands

Share your tips or issues concerning the WAPT Console or WAPT Agent here
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

March 22, 2018 - 1:24 PM

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 generate-uuid".

I tried as follows, but gave error.

Code: Select all

# -*- 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')
Last edited by empbilly on March 26, 2018 - 9:30 PM, edited 3 times.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

March 22, 2018 - 2:01 PM

You can get inspired by this package:

https://wapt.lesfourmisduweb.org/detail ... 3_all.wapt
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

March 22, 2018 - 2:16 PM

sfonteneau wrote: March 22, 2018 - 2:01 p.m. 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
Registration: January 15, 2018 - 8:59 PM

March 23, 2018 - 9:27 PM

sfonteneau,

Regarding my example,

Code: Select all

run(r'c:\windows\system32\cmd.exe /c wapt-get generete-uuid')
Would this work via WAPT?
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

March 24, 2018 - 00:26

Theoretically,

Code: Select all

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
Registration: January 15, 2018 - 8:59 PM

March 26, 2018 - 2:41 PM

htouvet wrote: March 24, 2018 - 00:26 Theoretically,

Code: Select all

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?
User avatar
dcardon
WAPT Expert
Messages: 1930
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

March 26, 2018 - 7:35 PM

Hi Empbilly,
empbilly wrote: March 26, 2018 - 2:41 p.m. 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
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

March 26, 2018 - 9:30 PM

The answer is in the topic of the link below.

viewtopic.php?f=10&t=1083
Locked