Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Python module to run command line programs in a very convenient way.

Project description



This python module provides a convenient interface to execute commands and catch their output.

Information about this module can be found here:

How to use this module


To import this module use the following statement:

import jk_simpleexec


Here is an example how to use this module:

result = invokeCmd("/bin/ls", [ "/proc/1", "-l" ])


# Synchroneously invokes the specified command. Output of STDOUT and STDERR is caught.
# @param		string cmdPath				The (absolute) path to the program to invoke
# @param		string[] cmdArgs			A list of arguments. Specify <c>None</c> if you do not want to have any arguments.
# @param		string onErrorExceptionMsg	If you specify an error message here an exception is thrown. If <c>None</c> is specified
#											<c>None</c> will be returned and no exception will be thrown.
# @return		CommandOutput				Returns an object representing the results.
def invokeCmd(cmdPath, cmdArgs, bRemoveTrailingNewLinesFromStdOut = True, bRemoveTrailingNewLinesFromStdErr = True)

CommandResult Object

# The return code of the command after completion.
# @return		int			The return code.
def returnCode(self)
# The STDOUT output of the command.
# @return		string[]		The output split into seperate lines. This property always returns a list, never <c>None</c>.
def stdOutLines(self)
# The STDERR output of the command.
# @return		string[]		The output split into seperate lines. This property always returns a list, never <c>None</c>.
def stdErrLines(self)
# Returns <c>True</c> iff the return code is not zero or <c>STDERR</c> contains data
def isError(self)
# If the return code is not zero or <c>STDERR</c> contains data
# an exception is thrown using the specified exception message.
# @param		string exceptionMessage			The message for the exception raised.
# @return		CommandOutput					If no exception is raised the object itself is returned.
def raiseExceptionOnError(self, exceptionMessage)
# Write all data to STDOUT. This method is provided for debugging purposes of your software.
def dump(self)
# Returns a dictionary containing all data.
# @return		dict			Returns a dictionary with data registered at the following keys:
#								"cmd", "cmdArgs", "stdOut", "stdErr", "retCode"
def toJSON(self)

Contact Information

This is Open Source code. That not only gives you the possibility of freely using this code it also allows you to contribute. Feel free to contact the author(s) of this software listed below, either for comments, collaboration requests, suggestions for improvement or reporting bugs:


This software is provided under the following license:

  • Apache Software License 2.0

Project details

Download files

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

Files for jk-simpleexec, version 0.2019.9.12
Filename, size File type Python version Upload date Hashes
Filename, size jk_simpleexec-0.2019.9.12.tar.gz (8.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page