Skip to main content

Run shell commands with python and get returncode,outputs as python variables. Also it will simultaneously print the outputs

Project description

SHELLIT (shell it)

shellit(shell it) is a package that will easily let you run shell commands from python and return your outputs.

Motivation

As a developer I need to run shell commands and check the output and based on the outputI make the decision. So to help developers who just want to run some shell commands with python here is the simple module :) Just install and run shell commands.

Setup

pip install shellit

from shellit import execute_cmd
outputfilename = 'shellit_output.txt'
cmd = "ls"
returncode, output = execute_cmd(cmd, shell=True, forced=False, outputfilename=outputfilename)

### Explaination ###

'''
    @param cmd(str) : cmd is a string which you want to execute with shell
    @param shell(bool) : shell is set to True to execute all commands in shell without any restrictions
    @param force(bool) : force to execute all commands even rm command.
    @param outputfilename(str) : name of the file in which output will be saved.
                              'shellit_output.txt' ($DEFAULT)  
    return 'returncode'(int) : 0 for successful.
                                any other num for unsuccessful command or if any error is thrown by the command.
            'output'(str) : An output string 
    '''

## console output ##

Executing cmd 'ls'
__init__.py
extra_feature_test
shellit.py
shellit_output.txt
cmd successful : 'ls'

## output finished ##

## Variable values ##
returncode = 0
output = "__init__.py\nextra_feature_test\nshellit.py\nshellit_output.txt"
##                 ##


returncode = 0 # Successful 
returncode !=0 # Unsuccessful



TO DO

  • execute shell commands

  • saving and return outputs

  • Simultaneously printing and saving the output

  • Testing on large output

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

shellit-0.0.4.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

shellit-0.0.4-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file shellit-0.0.4.tar.gz.

File metadata

  • Download URL: shellit-0.0.4.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for shellit-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5ca66c4e8011c63dbe0090799a7e0e43b332f9d45f83a8e256726159946ddf79
MD5 48d2ffc1703eb9ccc0510ed7fbe6df22
BLAKE2b-256 0e0b6fd245405029c1ee48a5d61e1c44a63db8c70cd945d8ff586dd1e5525ab6

See more details on using hashes here.

File details

Details for the file shellit-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: shellit-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for shellit-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0f98e134dacc45bbb4bc35dd2655671ab0a5b9a5772f14f83e50414a67c8f104
MD5 3d34fe78e9ac540a5e9c15b6f1c834b8
BLAKE2b-256 4bed5d853e2f1011bdf48bc88c72dd75f5ddb75326040edd69c6c76d61e4b0e6

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