Server IP : 37.60.233.201  /  Your IP : 216.73.217.25
Web Server : Apache
System : Linux host.ivahost.com 4.18.0-553.107.1.lve.el8.x86_64 #1 SMP Tue Feb 24 21:12:31 UTC 2026 x86_64
User : dcaksa ( 1043)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /etc/ld.so.conf.d/../scl/../cl.python/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //etc/ld.so.conf.d/../scl/../cl.python/../exec_command.py
# -*- coding: utf-8 -*-

# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT

from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import subprocess
import shlex


def parse_command(command):
    """
    Parses a command string into a list of arguments.
    """
    if isinstance(command, str):
        if command.strip() == "":
            return []
        return shlex.split(command)
    elif isinstance(command, list):
        return command
    else:
        return []

def exec_command(command, env=None):
    """
    Execute command
    """
    result = []
    try:
        args = parse_command(command)
        if not args:
            raise ValueError(f"The provided command is not valid: {command}")
        p = subprocess.Popen(args, stdout=subprocess.PIPE, env=env, text=True)
        while 1:
            output = p.stdout.readline()
            if not output:
                break
            if output.strip() != "":
                result.append(output.strip())
    except Exception as inst:
        print("Call process error:", str(inst))
    return result


def exec_command_check(command, env=None):
    """
    Execute command and check output
    """
    try:
        args = parse_command(command)
        if not args:
            raise ValueError(f"The provided command is not valid: {command}")
        p = subprocess.Popen(args, stdout=subprocess.PIPE, env=env, text=True)
        (res_in_json, err) = p.communicate()
        if (p.returncode != 0):
            return False
        return True
    except Exception as inst:
        print("Call process error(" + command + "): " + str(inst))
    return False