Skip to main content

No project description provided

Project description

⚓ shellxec ⚓

Shellxec is a Python library for running shell commands on both Windows and Linux systems. This library can be used to execute shell command from Python. This can be used to run codes in other languages such as C++, Java or Rust directly from Python and can also retain results if required.

Python is very much slow copared to other languages such as C++, Java or Rust. This library can be used to perform speed up the complex tasks and calculations by running them in other languages, while retaining the output in Python for further use.

Installation

You can install shellxec using pip:

pip install shellxec

Usage

Basic Usage

Import the shellxec library and call the method for it:

Basic example to compile a CPP/C++ file

import shellxec as sx

# Compile a CPP file 
command = "g++ main.cpp"  
sx.run_command(command)

Run a Shell Command

command = "echo 'Hello, ShellExec!'"
sx.run_command(command)

Run a Shell Command and Capture Output (String)

command = "echo 'Hello, ShellExec!'"
output = sx.run_command(command=command, output=True)
print("Output: ", output)

Advanced Usage

Run a Command in a Specific Directory

command = "dir"
directory = "hello"
sx.run_command_in_directory(command, directory)

Run a Command in a Specific Directory while retaining the output (String)

command = "dir"
directory = "hello"
result = sx.run_command_in_directory(command, directory, output=True)
print(result)

Run a Command with Custom Environment Variables

command = "echo $MY_VARIABLE"
env = {"MY_VARIABLE": "Hello from ShellExec"}
sx.run_command_with_env_var(command, env)

Run a Command with Custom Environment Variables while retaining the output (String)

command = "echo $MY_VARIABLE"
env = {"MY_VARIABLE": "Hello from ShellExec"}
result = sx.run_command_with_env_var(command, env, output=True)
print(result)

Run a Batch of Commands

commands = ["echo 'Command 1'", "echo 'Command 2'", "echo 'Command 3'"]
sx.run_commands_batch(commands)

Run a Batch of Commands while retaining the output (Array)

commands = ["echo 'Command 1'", "echo 'Command 2'", "echo 'Command 3'"]
result = sx.run_commands_batch(commands, output=True)
print(result) 

Running Tests

Status: Wrote Tests (Need more test cases)

Checklist:

  • Test Cases
  • Save To File Option

License

This project is not under any License (YET).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shellxec-0.1.7.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shellxec-0.1.7-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file shellxec-0.1.7.tar.gz.

File metadata

  • Download URL: shellxec-0.1.7.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for shellxec-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9fe661b5b2def5dd2feb0a9c46941767bc5354caf226c6fe783ababb893da2b6
MD5 35ab95f536aa776e204f6aca95e1516e
BLAKE2b-256 ac2f80016018c1705462d0b7cd3667960427c1ebd9a39449b12815022f4d2bc4

See more details on using hashes here.

File details

Details for the file shellxec-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: shellxec-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for shellxec-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a6489c2d173b88c935b2280bc6131e17e7aa517545e95a77736afbeda62cb31c
MD5 d47c5d7750048c7650e87cd8e5f5d77f
BLAKE2b-256 7d1738982ea7248329e435c7b3f415fdd6ec08cac3e46f60fe3009435a806de4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page