Interact with subprocesses running both bash.exe (CygWin) and cmd.exe without terminating them.
pip install cmdbashinteractive
Args:
print_stdout (bool, optional): Whether to print stdout from the subprocess (default is True).
print_stderr (bool, optional): Whether to print stderr from the subprocess (default is True).
limit_stdout (int, optional): Maximum number of lines to keep in stdout history (default is None).
limit_stderr (int, optional): Maximum number of lines to keep in stderr history (default is None).
limit_stdin (int, optional): Maximum number of lines to keep in stdin history (default is None).
convert_to_83 (bool, optional): Whether to convert file paths to short (8.3) format (default is True).
exitcommand (str, optional): The command to signal the subprocess to exit (default is "▓▓▓▓▓▓▓▓▓▓▓").
newline (str, optional): The newline character to use (default is "\n").
getcomspec (str, optional): The command to get the shell executable (default is "bash.exe").
wait_to_complete (float, optional): The time to wait for subprocess completion (default is 0.1 seconds).
**kwargs: Additional keyword arguments for subprocess.Popen.
import os
from cmdbashinteractive import BashInteractive, CmdInteractive
CREATE_NEW_PROCESS_GROUP = 0x00000200
DETACHED_PROCESS = 0x00000008
sh = BashInteractive(
print_stdout=True,
print_stderr=True,
limit_stdout=None,
limit_stderr=None,
limit_stdin=None,
convert_to_83=True,
exitcommand="▓▓▓▓▓▓▓▓▓▓▓",
newline="\n",
getcomspec=r"C:\cygwin\bin\bash.exe",
wait_to_complete=0.1,
shell=False, # **kwargs
creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, # **kwargs
bufsize=0, # **kwargs
env=os.environ.copy(), # **kwargs
)
stdo00, stde00 = sh("ls")
sh.install("tar")
stdo01, stde01 = sh("ping google.com | grep bytes")
stdo02, stde02 = sh(
r"cat C:\yolov5max - Copy\2023_08_17.ini"
) # automatically converted to 8.3 and afterwards to cygwin when convert_to_83 is True
Args:
print_stdout (bool, optional): Whether to print stdout from the subprocess (default is True).
print_stderr (bool, optional): Whether to print stderr from the subprocess (default is True).
limit_stdout (int, optional): Maximum number of lines to keep in stdout history (default is None).
limit_stderr (int, optional): Maximum number of lines to keep in stderr history (default is None).
limit_stdin (int, optional): Maximum number of lines to keep in stdin history (default is None).
convert_to_83 (bool, optional): Whether to convert file paths to short (8.3) format (default is True).
exitcommand (str, optional): The command to signal the subprocess to exit (default is "▓▓▓▓▓▓▓▓▓▓▓").
getcomspec (str, optional): The command to get the shell executable (default is None).
newline (str, optional): The newline character to use (default is "\r\n").
wait_to_complete (float, optional): The interval to check for subprocess completion (default is 0.1 seconds).
**kwargs: Additional keyword arguments for subprocess.Popen.
cmd = CmdInteractive(
print_stdout=True,
print_stderr=True,
limit_stdout=10,
limit_stderr=10,
limit_stdin=10,
convert_to_83=True,
exitcommand="▓▓▓▓▓▓▓▓▓▓▓",
wait_to_complete=0.1,
shell=False, # **kwargs
creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, # **kwargs
bufsize=0, # **kwargs
env=os.environ.copy(), # **kwargs
getcomspec=None,
newline="\r\n",
)
#
strfi = sh(
r"strings C:\yolov5max - Copy\2023_08_17.ini"
) # automatically converted to 8.3 when convert_to_83 is True
stdo0, stde0 = cmd(f"ping google.com", wait_to_complete=0.1)
stdo1, stde1 = cmd(f"dir", wait_to_complete=0.1)
stdo2, stde2 = cmd(f"whoami.exe", wait_to_complete=0.1)
stdo3, stde3 = cmd(
f"ping google.com", wait_to_complete=0
) # non blocking, not recommended - might mess up stdout,stderr
stdo4, stde4 = cmd(
f"dir", wait_to_complete=0
) # non blocking, not recommended - might mess up stdout,stderr
stdo5, stde5 = cmd(
f"whoami.exe", wait_to_complete=0
) # non blocking, not recommended - might mess up stdout,stderr
Metadata
Release files for cmdbashinteractive 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cmdbashinteractive-0.10.tar.gz | 15.3 kB | Without provenance | Details for cmdbashinteractive-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cmdbashinteractive-0.10-py3-none-any.whl | Python 3 | none | any | Details for cmdbashinteractive-0.10-py3-none-any.whl |
Total release size: 32.0 kB
Release files / cmdbashinteractive-0.10.tar.gz
| Download URL | cmdbashinteractive-0.10.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9a505abf66aba21ec9713503e992614cc1af44d52e0b3b45a19015888cb0d1a
|
|
BLAKE2b-256 checksum How to use checksums |
ca0b75e1722b11cd7323500b130f99efdd1cc4da75b52d67ebd285a9142e9f27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / cmdbashinteractive-0.10-py3-none-any.whl
| Download URL | cmdbashinteractive-0.10-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdcc9df49c60da7b8d3489419bdb0310493d8fe13096cd1fc33bd9bbd869afd8
|
|
BLAKE2b-256 checksum How to use checksums |
19f128d8a587c15a2c12004bd2afaa61a73a69cde83cb424dbbf8d690adeedbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for cmdbashinteractive 0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.