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.
You can install shellxec using pip:
pip install shellxecImport 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)command = "echo 'Hello, ShellExec!'"
sx.run_command(command)command = "echo 'Hello, ShellExec!'"
output = sx.run_command(command=command, output=True)
print("Output: ", output)command = <dir>
directory = "hello"
sx.run_command_in_directory(command, directory)command = <dir>
directory = "hello"
result = sx.run_command_in_directory(command, directory, output=True)
print(result)command = "echo $MY_VARIABLE"
env = {"MY_VARIABLE": "Hello from ShellExec"}
sx.run_command_with_env_var(command, env)command = "echo $MY_VARIABLE"
env = {"MY_VARIABLE": "Hello from ShellExec"}
result = sx.run_command_with_env_var(command, env, output=True)
print(result)commands = ["echo 'Command 1'", "echo 'Command 2'", "echo 'Command 3'"]
sx.run_commands_batch(commands)commands = ["echo 'Command 1'", "echo 'Command 2'", "echo 'Command 3'"]
result = sx.run_commands_batch(commands, output=True)
print(result) Status: Wrote Tests (Need more test cases)
- Start Documentation
- Write more test cases
- Check for PEP8 Standardization throughout the project
- Save To File Option
- Begin Creating Documentation
This project is not under any License (YET).